2 * Copyright (C) 2003 Robert Kooima
4 * NEVERBALL is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published
6 * by the Free Software Foundation; either version 2 of the License,
7 * or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
20 #define V_PI 3.1415927f
22 #define V_RAD(d) (d * V_PI / 180.f)
23 #define V_DEG(r) (r * 180.f / V_PI)
25 #define fsinf(a) ((float) sin((double) a))
26 #define fcosf(a) ((float) cos((double) a))
27 #define ftanf(a) ((float) cos((double) a))
28 #define fabsf(a) ((float) fabs((double) a))
29 #define fsqrtf(a) ((float) sqrt((double) a))
30 #define facosf(a) ((float) acos((double) a))
31 #define fmodf(x,y) ((float) fmod((double) x, (double) y))
32 #define fatan2f(x, y) ((float) atan2((double) x, (double) y))
34 /*---------------------------------------------------------------------------*/
36 #define v_dot(u, v) ((u)[0] * (v)[0] + (u)[1] * (v)[1] + (u)[2] * (v)[2])
37 #define v_len(u) fsqrtf(v_dot(u, u))
39 #define v_cpy(u, v) { \
45 #define v_inv(u, v) { \
51 #define v_scl(u, v, k) { \
52 (u)[0] = (v)[0] * (k); \
53 (u)[1] = (v)[1] * (k); \
54 (u)[2] = (v)[2] * (k); \
57 #define v_add(u, v, w) { \
58 (u)[0] = (v)[0] + (w)[0]; \
59 (u)[1] = (v)[1] + (w)[1]; \
60 (u)[2] = (v)[2] + (w)[2]; \
63 #define v_sub(u, v, w) { \
64 (u)[0] = (v)[0] - (w)[0]; \
65 (u)[1] = (v)[1] - (w)[1]; \
66 (u)[2] = (v)[2] - (w)[2]; \
69 #define v_mid(u, v, w) { \
70 (u)[0] = ((v)[0] + (w)[0]) / 2.f; \
71 (u)[1] = ((v)[1] + (w)[1]) / 2.f; \
72 (u)[2] = ((v)[2] + (w)[2]) / 2.f; \
75 #define v_mad(u, p, v, t) { \
76 (u)[0] = (p)[0] + (v)[0] * (t); \
77 (u)[1] = (p)[1] + (v)[1] * (t); \
78 (u)[2] = (p)[2] + (v)[2] * (t); \
81 /*---------------------------------------------------------------------------*/
84 void v_nrm(float *, const float *);
85 void v_crs(float *, const float *, const float *);
87 void m_cpy(float *, const float *);
88 void m_xps(float *, const float *);
89 int m_inv(float *, const float *);
91 void m_ident(float *);
92 void m_basis(float *, const float *,
96 void m_xlt(float *, const float *);
97 void m_scl(float *, const float *);
98 void m_rot(float *, const float *, float);
100 void m_mult(float *, const float *, const float *);
101 void m_pxfm(float *, const float *, const float *);
102 void m_vxfm(float *, const float *, const float *);