]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - tools/quake2/extra/qe4/mathlib.h
Merge branch 'NateEag-master-patch-12920' into 'master'
[xonotic/netradiant.git] / tools / quake2 / extra / qe4 / mathlib.h
1 /*
2 ===========================================================================
3 Copyright (C) 1997-2006 Id Software, Inc.
4
5 This file is part of Quake 2 Tools source code.
6
7 Quake 2 Tools source code is free software; you can redistribute it
8 and/or modify it under the terms of the GNU General Public License as
9 published by the Free Software Foundation; either version 2 of the License,
10 or (at your option) any later version.
11
12 Quake 2 Tools source code is distributed in the hope that it will be
13 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with Quake 2 Tools source code; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20 ===========================================================================
21 */
22
23 #ifndef __MATHLIB__
24 #define __MATHLIB__
25
26 // mathlib.h
27
28 #include <math.h>
29
30 typedef float vec_t;
31 typedef vec_t vec3_t[3];
32
33 #define SIDE_FRONT              0
34 #define SIDE_ON                 2
35 #define SIDE_BACK               1
36 #define SIDE_CROSS              -2
37
38 #define Q_PI    3.14159265358979323846
39
40 extern vec3_t vec3_origin;
41
42 #define EQUAL_EPSILON   0.001
43
44 qboolean VectorCompare (vec3_t v1, vec3_t v2);
45
46 #define DotProduct(x,y) (x[0]*y[0]+x[1]*y[1]+x[2]*y[2])
47 #define VectorSubtract(a,b,c) {c[0]=a[0]-b[0];c[1]=a[1]-b[1];c[2]=a[2]-b[2];}
48 #define VectorAdd(a,b,c) {c[0]=a[0]+b[0];c[1]=a[1]+b[1];c[2]=a[2]+b[2];}
49 #define VectorCopy(a,b) {b[0]=a[0];b[1]=a[1];b[2]=a[2];}
50
51 vec_t Q_rint (vec_t in);
52 vec_t _DotProduct (vec3_t v1, vec3_t v2);
53 void _VectorSubtract (vec3_t va, vec3_t vb, vec3_t out);
54 void _VectorAdd (vec3_t va, vec3_t vb, vec3_t out);
55 void _VectorCopy (vec3_t in, vec3_t out);
56
57 float VectorLength(vec3_t v);
58
59 void VectorMA (vec3_t va, float scale, vec3_t vb, vec3_t vc);
60
61 void CrossProduct (vec3_t v1, vec3_t v2, vec3_t cross);
62 vec_t VectorNormalize (vec3_t v);
63 void VectorInverse (vec3_t v);
64 void VectorScale (vec3_t v, vec_t scale, vec3_t out);
65
66 #endif