Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

l_math.h

Go to the documentation of this file.
00001 /*
00002 ===========================================================================
00003 Copyright (C) 1999-2005 Id Software, Inc.
00004 
00005 This file is part of Quake III Arena source code.
00006 
00007 Quake III Arena source code is free software; you can redistribute it
00008 and/or modify it under the terms of the GNU General Public License as
00009 published by the Free Software Foundation; either version 2 of the License,
00010 or (at your option) any later version.
00011 
00012 Quake III Arena source code is distributed in the hope that it will be
00013 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 GNU General Public License for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with Foobar; if not, write to the Free Software
00019 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00020 ===========================================================================
00021 */
00022 #ifndef __MATHLIB__
00023 #define __MATHLIB__
00024 
00025 // mathlib.h
00026 
00027 #include <math.h>
00028 
00029 #ifdef DOUBLEVEC_T
00030 typedef double vec_t;
00031 #else
00032 typedef float vec_t;
00033 #endif
00034 typedef vec_t vec3_t[3];
00035 typedef vec_t vec4_t[4];
00036 
00037 #define SIDE_FRONT      0
00038 #define SIDE_ON         2
00039 #define SIDE_BACK       1
00040 #define SIDE_CROSS      -2
00041 
00042 #define PITCH       0
00043 #define YAW         1
00044 #define ROLL        2
00045 
00046 #define Q_PI    3.14159265358979323846
00047 
00048 #define DEG2RAD( a ) ( a * M_PI ) / 180.0F
00049 
00050 #ifndef M_PI
00051 #define M_PI        3.14159265358979323846  // matches value in gcc v2 math.h
00052 #endif
00053 
00054 extern vec3_t vec3_origin;
00055 
00056 #define EQUAL_EPSILON   0.001
00057 
00058 qboolean VectorCompare (vec3_t v1, vec3_t v2);
00059 
00060 #define DotProduct(x,y)         (x[0]*y[0]+x[1]*y[1]+x[2]*y[2])
00061 #define VectorSubtract(a,b,c)   {c[0]=a[0]-b[0];c[1]=a[1]-b[1];c[2]=a[2]-b[2];}
00062 #define VectorAdd(a,b,c)        {c[0]=a[0]+b[0];c[1]=a[1]+b[1];c[2]=a[2]+b[2];}
00063 #define VectorCopy(a,b)         {b[0]=a[0];b[1]=a[1];b[2]=a[2];}
00064 #define Vector4Copy(a,b)        {b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];}
00065 #define VectorScale(v, s, o)    ((o)[0]=(v)[0]*(s),(o)[1]=(v)[1]*(s),(o)[2]=(v)[2]*(s))
00066 #define VectorClear(x)          {x[0] = x[1] = x[2] = 0;}
00067 #define VectorNegate(x, y)      {y[0]=-x[0];y[1]=-x[1];y[2]=-x[2];}
00068 #define VectorMA(v, s, b, o)    ((o)[0]=(v)[0]+(b)[0]*(s),(o)[1]=(v)[1]+(b)[1]*(s),(o)[2]=(v)[2]+(b)[2]*(s))
00069 
00070 vec_t Q_rint (vec_t in);
00071 vec_t _DotProduct (vec3_t v1, vec3_t v2);
00072 void _VectorSubtract (vec3_t va, vec3_t vb, vec3_t out);
00073 void _VectorAdd (vec3_t va, vec3_t vb, vec3_t out);
00074 void _VectorCopy (vec3_t in, vec3_t out);
00075 void _VectorScale (vec3_t v, vec_t scale, vec3_t out);
00076 void _VectorMA(vec3_t va, double scale, vec3_t vb, vec3_t vc);
00077 
00078 double VectorLength(vec3_t v);
00079 void CrossProduct(const vec3_t v1, const vec3_t v2, vec3_t cross);
00080 vec_t VectorNormalize(vec3_t inout);
00081 vec_t ColorNormalize(vec3_t in, vec3_t out);
00082 vec_t VectorNormalize2(const vec3_t v, vec3_t out);
00083 void VectorInverse (vec3_t v);
00084 
00085 void ClearBounds (vec3_t mins, vec3_t maxs);
00086 void AddPointToBounds (const vec3_t v, vec3_t mins, vec3_t maxs);
00087 
00088 void AngleVectors (const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up);
00089 void R_ConcatRotations (float in1[3][3], float in2[3][3], float out[3][3]);
00090 void RotatePoint(vec3_t point, float matrix[3][3]);
00091 void CreateRotationMatrix(vec3_t angles, float matrix[3][3]);
00092 
00093 #endif

Generated on Thu Aug 25 12:37:17 2005 for Quake III Arena by  doxygen 1.3.9.1