aboutsummaryrefslogtreecommitdiffstats
path: root/code/tools/q3asm/mathlib.h
diff options
context:
space:
mode:
authortma <tma@edf5b092-35ff-0310-97b2-ce42778d08ea>2005-10-04 15:18:22 +0000
committertma <tma@edf5b092-35ff-0310-97b2-ce42778d08ea>2005-10-04 15:18:22 +0000
commit1c7864f6d4380797b07c7149111066b61f69f689 (patch)
tree59057c26f97fdf846b0193e852eeea7e707a9e20 /code/tools/q3asm/mathlib.h
parent91db83f0cc7c564ff6c853eeb4e790732dae81cd (diff)
downloadioquake3-aero-1c7864f6d4380797b07c7149111066b61f69f689.tar.gz
ioquake3-aero-1c7864f6d4380797b07c7149111066b61f69f689.zip
* Moved lcc and q3asm into code/tools
git-svn-id: svn://svn.icculus.org/quake3/trunk@134 edf5b092-35ff-0310-97b2-ce42778d08ea
Diffstat (limited to 'code/tools/q3asm/mathlib.h')
-rw-r--r--code/tools/q3asm/mathlib.h94
1 files changed, 94 insertions, 0 deletions
diff --git a/code/tools/q3asm/mathlib.h b/code/tools/q3asm/mathlib.h
new file mode 100644
index 0000000..f88bf58
--- /dev/null
+++ b/code/tools/q3asm/mathlib.h
@@ -0,0 +1,94 @@
+/*
+===========================================================================
+Copyright (C) 1999-2005 Id Software, Inc.
+
+This file is part of Quake III Arena source code.
+
+Quake III Arena source code is free software; you can redistribute it
+and/or modify it under the terms of the GNU General Public License as
+published by the Free Software Foundation; either version 2 of the License,
+or (at your option) any later version.
+
+Quake III Arena source code is distributed in the hope that it will be
+useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Foobar; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+===========================================================================
+*/
+#ifndef __MATHLIB__
+#define __MATHLIB__
+
+// mathlib.h
+
+#include <math.h>
+
+#ifdef DOUBLEVEC_T
+typedef double vec_t;
+#else
+typedef float vec_t;
+#endif
+typedef vec_t vec2_t[3];
+typedef vec_t vec3_t[3];
+typedef vec_t vec4_t[4];
+
+#define SIDE_FRONT 0
+#define SIDE_ON 2
+#define SIDE_BACK 1
+#define SIDE_CROSS -2
+
+#define Q_PI 3.14159265358979323846
+#define DEG2RAD( a ) ( ( (a) * Q_PI ) / 180.0F )
+#define RAD2DEG( a ) ( ( (a) * 180.0f ) / Q_PI )
+
+extern vec3_t vec3_origin;
+
+#define EQUAL_EPSILON 0.001
+
+// plane types are used to speed some tests
+// 0-2 are axial planes
+#define PLANE_X 0
+#define PLANE_Y 1
+#define PLANE_Z 2
+#define PLANE_NON_AXIAL 3
+
+qboolean VectorCompare( const vec3_t v1, const vec3_t v2 );
+
+#define DotProduct(x,y) (x[0]*y[0]+x[1]*y[1]+x[2]*y[2])
+#define VectorSubtract(a,b,c) {c[0]=a[0]-b[0];c[1]=a[1]-b[1];c[2]=a[2]-b[2];}
+#define VectorAdd(a,b,c) {c[0]=a[0]+b[0];c[1]=a[1]+b[1];c[2]=a[2]+b[2];}
+#define VectorCopy(a,b) {b[0]=a[0];b[1]=a[1];b[2]=a[2];}
+#define VectorScale(a,b,c) {c[0]=b*a[0];c[1]=b*a[1];c[2]=b*a[2];}
+#define VectorClear(x) {x[0] = x[1] = x[2] = 0;}
+#define VectorNegate(x) {x[0]=-x[0];x[1]=-x[1];x[2]=-x[2];}
+void Vec10Copy( vec_t *in, vec_t *out );
+
+vec_t Q_rint (vec_t in);
+vec_t _DotProduct (vec3_t v1, vec3_t v2);
+void _VectorSubtract (vec3_t va, vec3_t vb, vec3_t out);
+void _VectorAdd (vec3_t va, vec3_t vb, vec3_t out);
+void _VectorCopy (vec3_t in, vec3_t out);
+void _VectorScale (vec3_t v, vec_t scale, vec3_t out);
+
+double VectorLength( const vec3_t v );
+
+void VectorMA( const vec3_t va, double scale, const vec3_t vb, vec3_t vc );
+
+void CrossProduct( const vec3_t v1, const vec3_t v2, vec3_t cross );
+vec_t VectorNormalize( const vec3_t in, vec3_t out );
+vec_t ColorNormalize( const vec3_t in, vec3_t out );
+void VectorInverse (vec3_t v);
+
+void ClearBounds (vec3_t mins, vec3_t maxs);
+void AddPointToBounds( const vec3_t v, vec3_t mins, vec3_t maxs );
+
+qboolean PlaneFromPoints( vec4_t plane, const vec3_t a, const vec3_t b, const vec3_t c );
+
+void NormalToLatLong( const vec3_t normal, byte bytes[2] );
+
+int PlaneTypeForNormal (vec3_t normal);
+
+#endif