10 static float clamp(float val, float min, float max);
12 // Simple wrappers around library routines
13 static float abs(float f);
14 static float sqrt(float f);
15 static float sqr(float f);
16 static float ceil(float f);
17 static float sin(float f);
18 static float cos(float f);
19 static float tan(float f);
20 static float atan(float f);
21 static float atan2(float y, float x);
22 static float asin(float f);
23 static float acos(float f);
25 // Takes two args and runs afoul of the Koenig rules.
26 static float pow(double base, double exp);
28 // double variants of the above
29 static double abs(double f);
30 static double sqrt(double f);
31 static double ceil(double f);
32 static double sin(double f);
33 static double cos(double f);
34 static double tan(double f);
35 static double atan2(double y, double x);
37 // Some 3D vector stuff. In all cases, it is permissible for the
38 // "out" vector to be the same as one of the inputs.
39 static void set3(float* v, float* out);
40 static float dot3(float* a, float* b);
41 static void cross3(float* a, float* b, float* out);
42 static void mul3(float scalar, float* v, float* out);
43 static void add3(float* a, float* b, float* out);
44 static void sub3(float* a, float* b, float* out);
45 static float mag3(float* v);
46 static void unit3(float* v, float* out);
48 // Matrix array convention: 0 1 2
52 // Multiply two matrices
53 static void mmul33(float* a, float* b, float* out);
56 static void vmul33(float* m, float* v, float* out);
58 // Multiply the vector by the matrix transpose. Or pre-multiply the
59 // matrix by v as a row vector. Same thing.
60 static void tmul33(float* m, float* v, float* out);
63 static void invert33(float* m, float* out);
65 // Transpose matrix (for an orthonormal orientation matrix, this
66 // is the same as the inverse).
67 static void trans33(float* m, float* out);
69 // Generates an orthonormal basis:
70 // xOut becomes the unit vector in the direction of x
71 // yOut is perpendicular to xOut in the x/y plane
72 // zOut becomes the unit vector: (xOut cross yOut)
73 static void ortho33(float* x, float* y,
74 float* xOut, float* yOut, float* zOut);