|
|
1.1 root 1: // mathlib.h
2:
3: typedef float vec_t;
4: typedef vec_t vec3_t[3];
5: typedef vec_t vec5_t[5];
6:
7: typedef int fixed4_t;
8: typedef int fixed8_t;
9: typedef int fixed16_t;
10:
11: #ifndef M_PI
12: #define M_PI 3.14159265358979323846 // matches value in gcc v2 math.h
13: #endif
14:
15: struct mplane_s;
16:
17: extern vec3_t vec3_origin;
18: extern int nanmask;
19:
20: #define IS_NAN(x) (((*(int *)&x)&nanmask)==nanmask)
21:
22: #define DotProduct(x,y) (x[0]*y[0]+x[1]*y[1]+x[2]*y[2])
23: #define VectorSubtract(a,b,c) {c[0]=a[0]-b[0];c[1]=a[1]-b[1];c[2]=a[2]-b[2];}
24: #define VectorAdd(a,b,c) {c[0]=a[0]+b[0];c[1]=a[1]+b[1];c[2]=a[2]+b[2];}
25: #define VectorCopy(a,b) {b[0]=a[0];b[1]=a[1];b[2]=a[2];}
26:
27: void VectorMA (vec3_t veca, float scale, vec3_t vecb, vec3_t vecc);
28:
29: vec_t _DotProduct (vec3_t v1, vec3_t v2);
30: void _VectorSubtract (vec3_t veca, vec3_t vecb, vec3_t out);
31: void _VectorAdd (vec3_t veca, vec3_t vecb, vec3_t out);
32: void _VectorCopy (vec3_t in, vec3_t out);
33:
34: int VectorCompare (vec3_t v1, vec3_t v2);
35: vec_t Length (vec3_t v);
36: void CrossProduct (vec3_t v1, vec3_t v2, vec3_t cross);
37: float VectorNormalize (vec3_t v); // returns vector length
38: void VectorInverse (vec3_t v);
39: void VectorScale (vec3_t in, vec_t scale, vec3_t out);
40: int Q_log2(int val);
41:
42: void R_ConcatRotations (float in1[3][3], float in2[3][3], float out[3][3]);
43: void R_ConcatTransforms (float in1[3][4], float in2[3][4], float out[3][4]);
44:
45: void FloorDivMod (double numer, double denom, int *quotient,
46: int *rem);
47: fixed16_t Invert24To16(fixed16_t val);
1.1.1.2 ! root 48: fixed16_t Mul16_30(fixed16_t multiplier, fixed16_t multiplicand);
1.1 root 49: int GreatestCommonDivisor (int i1, int i2);
50:
51: void AngleVectors (vec3_t angles, vec3_t forward, vec3_t right, vec3_t up);
52: int BoxOnPlaneSide (vec3_t emins, vec3_t emaxs, struct mplane_s *plane);
53: float anglemod(float a);
54:
55:
56:
57: #define BOX_ON_PLANE_SIDE(emins, emaxs, p) \
58: (((p)->type < 3)? \
59: ( \
60: ((p)->dist <= (emins)[(p)->type])? \
61: 1 \
62: : \
63: ( \
64: ((p)->dist >= (emaxs)[(p)->type])?\
65: 2 \
66: : \
67: 3 \
68: ) \
69: ) \
70: : \
71: BoxOnPlaneSide( (emins), (emaxs), (p)))
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.