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 typedef float vec_t;
00030 typedef vec_t vec3_t[3];
00031 typedef vec_t vec5_t[5];
00032 
00033 #define SIDE_FRONT      0
00034 #define SIDE_ON         2
00035 #define SIDE_BACK       1
00036 #define SIDE_CROSS      -2
00037 
00038 #define Q_PI    3.14159265358979323846
00039 
00040 extern vec3_t vec3_origin;
00041 
00042 #define EQUAL_EPSILON   0.001
00043 
00044 qboolean VectorCompare (vec3_t v1, vec3_t v2);
00045 
00046 #define DotProduct(x,y) (x[0]*y[0]+x[1]*y[1]+x[2]*y[2])
00047 #define VectorSubtract(a,b,c) {c[0]=a[0]-b[0];c[1]=a[1]-b[1];c[2]=a[2]-b[2];}
00048 #define VectorAdd(a,b,c) {c[0]=a[0]+b[0];c[1]=a[1]+b[1];c[2]=a[2]+b[2];}
00049 #define VectorCopy(a,b) {b[0]=a[0];b[1]=a[1];b[2]=a[2];}
00050 #define VectorSet(v, a, b, c) {v[0]=a;v[1]=b;v[2]=c;}
00051 
00052 vec_t Q_rint (vec_t in);
00053 vec_t _DotProduct (vec3_t v1, vec3_t v2);
00054 void _VectorSubtract (vec3_t va, vec3_t vb, vec3_t out);
00055 void _VectorAdd (vec3_t va, vec3_t vb, vec3_t out);
00056 void _VectorCopy (vec3_t in, vec3_t out);
00057 
00058 float VectorLength(vec3_t v);
00059 
00060 void VectorMA (vec3_t va, float scale, vec3_t vb, vec3_t vc);
00061 
00062 void CrossProduct (vec3_t v1, vec3_t v2, vec3_t cross);
00063 vec_t VectorNormalize (vec3_t v);
00064 void VectorInverse (vec3_t v);
00065 void VectorScale (vec3_t v, vec_t scale, vec3_t out);
00066 void VectorPolar(vec3_t v, float radius, float theta, float phi);
00067 void VectorSnap(vec3_t v);
00068 
00069 void _Vector53Copy (vec5_t in, vec3_t out);
00070 void _Vector5Scale (vec5_t v, vec_t scale, vec5_t out);
00071 void _Vector5Add (vec5_t va, vec5_t vb, vec5_t out);
00072 
00073 // NOTE: added these from Ritual's Q3Radiant
00074 void ClearBounds (vec3_t mins, vec3_t maxs);
00075 void AddPointToBounds (vec3_t v, vec3_t mins, vec3_t maxs);
00076 
00077 void AngleVectors (vec3_t angles, vec3_t forward, vec3_t right, vec3_t up);
00078 void VectorToAngles( vec3_t vec, vec3_t angles );
00079 #define VectorClear(x) {x[0] = x[1] = x[2] = 0;}
00080 
00081 #define ZERO_EPSILON 1.0E-6
00082 #define RAD2DEG( a ) ( ( (a) * 180.0f ) / Q_PI )
00083 #define DEG2RAD( a ) ( ( (a) * Q_PI ) / 180.0f )
00084 
00085 
00086 #endif

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