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

mathlib.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 vec2_t[3];
00035 typedef vec_t vec3_t[3];
00036 typedef vec_t vec4_t[4];
00037 
00038 #define SIDE_FRONT      0
00039 #define SIDE_ON         2
00040 #define SIDE_BACK       1
00041 #define SIDE_CROSS      -2
00042 
00043 #define Q_PI    3.14159265358979323846
00044 #define DEG2RAD( a ) ( ( (a) * Q_PI ) / 180.0F )
00045 #define RAD2DEG( a ) ( ( (a) * 180.0f ) / Q_PI )
00046 
00047 extern vec3_t vec3_origin;
00048 
00049 #define EQUAL_EPSILON   0.001
00050 
00051 // plane types are used to speed some tests
00052 // 0-2 are axial planes
00053 #define PLANE_X         0
00054 #define PLANE_Y         1
00055 #define PLANE_Z         2
00056 #define PLANE_NON_AXIAL 3
00057 
00058 qboolean VectorCompare( const vec3_t v1, const 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 VectorScale(a,b,c) {c[0]=b*a[0];c[1]=b*a[1];c[2]=b*a[2];}
00065 #define VectorClear(x) {x[0] = x[1] = x[2] = 0;}
00066 #define VectorNegate(x) {x[0]=-x[0];x[1]=-x[1];x[2]=-x[2];}
00067 void Vec10Copy( vec_t *in, vec_t *out );
00068 
00069 vec_t Q_rint (vec_t in);
00070 vec_t _DotProduct (vec3_t v1, vec3_t v2);
00071 void _VectorSubtract (vec3_t va, vec3_t vb, vec3_t out);
00072 void _VectorAdd (vec3_t va, vec3_t vb, vec3_t out);
00073 void _VectorCopy (vec3_t in, vec3_t out);
00074 void _VectorScale (vec3_t v, vec_t scale, vec3_t out);
00075 
00076 double VectorLength( const vec3_t v );
00077 
00078 void VectorMA( const vec3_t va, double scale, const vec3_t vb, vec3_t vc );
00079 
00080 void CrossProduct( const vec3_t v1, const vec3_t v2, vec3_t cross );
00081 vec_t VectorNormalize( const vec3_t in, vec3_t out );
00082 vec_t ColorNormalize( const vec3_t in, 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 qboolean PlaneFromPoints( vec4_t plane, const vec3_t a, const vec3_t b, const vec3_t c );
00089 
00090 void NormalToLatLong( const vec3_t normal, byte bytes[2] );
00091 
00092 int PlaneTypeForNormal (vec3_t normal);
00093 
00094 #endif

Generated on Thu Aug 25 12:38:08 2005 for Quake III Arena by  doxygen 1.3.9.1