-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvec.h
96 lines (74 loc) · 1.72 KB
/
vec.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#ifndef __VEC_H__
#define __VEC_H__
#define PITCH 0
#define YAW 1
#define ROLL 2
struct plane_s
{
float normal[3];
float dist;
unsigned char type;
unsigned char signbits;
unsigned char pad[2];
};
enum
{
PLANE_X, /* normal lies on x axis */
PLANE_Y, /* normal lies on y axis */
PLANE_Z, /* normal lies on z axis */
PLANE_NEAR_X, /* normal is closest to PLANE_X */
PLANE_NEAR_Y, /* normal is closest to PLANE_Y */
PLANE_NEAR_Z /* normal is closest to PLANE_Z */
};
enum
{
SIDE_FRONT,
SIDE_BACK,
SIDE_CROSS
};
#define PLANE_DIST_EPSILON 0.01
#define PLANE_NORMAL_EPSILON 0.00001
enum
{
ROT_MATRIX_ORDER_XYZ,
ROT_MATRIX_ORDER_XZY,
ROT_MATRIX_ORDER_YXZ,
ROT_MATRIX_ORDER_ZXY,
ROT_MATRIX_ORDER_YZX,
ROT_MATRIX_ORDER_ZYX
};
extern void
Vec_Clear (float v[3]);
extern void
Vec_Copy (const float src[3], float out[3]);
extern void
Vec_Scale (float v[3], float s);
extern void
Vec_Add (const float a[3], const float b[3], float out[3]);
extern void
Vec_Subtract (const float a[3], const float b[3], float out[3]);
extern float
Vec_Dot (const float a[3], const float b[3]);
extern void
Vec_Cross (const float a[3], const float b[3], float out[3]);
extern void
Vec_Normalize (float v[3]);
extern float
Vec_Length (const float v[3]);
extern void
Vec_SnapPlane (float normal[3], float *dist);
extern void
Vec_MakeNormal (const float v1[3],
const float v2[3],
const float v3[3],
float normal[3],
float *dist);
extern int
Vec_BoxPlaneSide (const struct plane_s *plane, float mins[3], float maxs[3]);
extern void
Vec_IdentityMatrix (float mat[3][3]);
extern void
Vec_MultMatrix (float a[3][3], float b[3][3], float out[3][3]);
extern void
Vec_AnglesMatrix (const float angles[3], float out[3][3], int order);
#endif /* __VEC_H__ */