]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - tools/quake2/common/mathlib.h
transfer from internal tree r5311 branches/1.4-gpl
[xonotic/netradiant.git] / tools / quake2 / common / mathlib.h
1 /*\r
2 Copyright (C) 1999-2007 id Software, Inc. and contributors.\r
3 For a list of contributors, see the accompanying CONTRIBUTORS file.\r
4 \r
5 This file is part of GtkRadiant.\r
6 \r
7 GtkRadiant is free software; you can redistribute it and/or modify\r
8 it under the terms of the GNU General Public License as published by\r
9 the Free Software Foundation; either version 2 of the License, or\r
10 (at your option) any later version.\r
11 \r
12 GtkRadiant is distributed in the hope that it will be useful,\r
13 but WITHOUT ANY WARRANTY; without even the implied warranty of\r
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
15 GNU General Public License for more details.\r
16 \r
17 You should have received a copy of the GNU General Public License\r
18 along with GtkRadiant; if not, write to the Free Software\r
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\r
20 */\r
21 #ifndef __MATHLIB__\r
22 #define __MATHLIB__\r
23 \r
24 // mathlib.h\r
25 \r
26 #include <math.h>\r
27 \r
28 #ifdef DOUBLEVEC_T\r
29 typedef double vec_t;\r
30 #else\r
31 typedef float vec_t;\r
32 #endif\r
33 typedef vec_t vec3_t[3];\r
34 \r
35 #define SIDE_FRONT              0\r
36 #define SIDE_ON                 2\r
37 #define SIDE_BACK               1\r
38 #define SIDE_CROSS              -2\r
39 \r
40 #define Q_PI    3.14159265358979323846\r
41 \r
42 extern vec3_t vec3_origin;\r
43 \r
44 #define EQUAL_EPSILON   0.001\r
45 \r
46 qboolean VectorCompare (vec3_t v1, vec3_t v2);\r
47 \r
48 #define DotProduct(x,y) (x[0]*y[0]+x[1]*y[1]+x[2]*y[2])\r
49 #define VectorSubtract(a,b,c) {c[0]=a[0]-b[0];c[1]=a[1]-b[1];c[2]=a[2]-b[2];}\r
50 #define VectorAdd(a,b,c) {c[0]=a[0]+b[0];c[1]=a[1]+b[1];c[2]=a[2]+b[2];}\r
51 #define VectorCopy(a,b) {b[0]=a[0];b[1]=a[1];b[2]=a[2];}\r
52 #define VectorScale(a,b,c) {c[0]=b*a[0];c[1]=b*a[1];c[2]=b*a[2];}\r
53 #define VectorClear(x) {x[0] = x[1] = x[2] = 0;}\r
54 #define VectorNegate(x) {x[0]=-x[0];x[1]=-x[1];x[2]=-x[2];}\r
55 \r
56 vec_t Q_rint (vec_t in);\r
57 vec_t _DotProduct (vec3_t v1, vec3_t v2);\r
58 void _VectorSubtract (vec3_t va, vec3_t vb, vec3_t out);\r
59 void _VectorAdd (vec3_t va, vec3_t vb, vec3_t out);\r
60 void _VectorCopy (vec3_t in, vec3_t out);\r
61 void _VectorScale (vec3_t v, vec_t scale, vec3_t out);\r
62 \r
63 double VectorLength(vec3_t v);\r
64 \r
65 void VectorMA (vec3_t va, double scale, vec3_t vb, vec3_t vc);\r
66 \r
67 void CrossProduct (vec3_t v1, vec3_t v2, vec3_t cross);\r
68 vec_t VectorNormalize (vec3_t in, vec3_t out);\r
69 vec_t ColorNormalize (vec3_t in, vec3_t out);\r
70 void VectorInverse (vec3_t v);\r
71 \r
72 void ClearBounds (vec3_t mins, vec3_t maxs);\r
73 void AddPointToBounds (vec3_t v, vec3_t mins, vec3_t maxs);\r
74 \r
75 #endif\r