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 fmodf(x,y) ((float) fmod((double) x, (double) y))
31 #define fatan2f(x, y) ((float) atan2((double) x, (double) y))
33 /*---------------------------------------------------------------------------*/
35 #define v_dot(u, v) ((u)[0] * (v)[0] + (u)[1] * (v)[1] + (u)[2] * (v)[2])
36 #define v_len(u) fsqrtf(v_dot(u, u))
38 #define v_cpy(u, v) { \
44 #define v_inv(u, v) { \
50 #define v_scl(u, v, k) { \
51 (u)[0] = (v)[0] * (k); \
52 (u)[1] = (v)[1] * (k); \
53 (u)[2] = (v)[2] * (k); \
56 #define v_add(u, v, w) { \
57 (u)[0] = (v)[0] + (w)[0]; \
58 (u)[1] = (v)[1] + (w)[1]; \
59 (u)[2] = (v)[2] + (w)[2]; \
62 #define v_sub(u, v, w) { \
63 (u)[0] = (v)[0] - (w)[0]; \
64 (u)[1] = (v)[1] - (w)[1]; \
65 (u)[2] = (v)[2] - (w)[2]; \
68 #define v_mid(u, v, w) { \
69 (u)[0] = ((v)[0] + (w)[0]) / 2.f; \
70 (u)[1] = ((v)[1] + (w)[1]) / 2.f; \
71 (u)[2] = ((v)[2] + (w)[2]) / 2.f; \
74 #define v_mad(u, p, v, t) { \
75 (u)[0] = (p)[0] + (v)[0] * (t); \
76 (u)[1] = (p)[1] + (v)[1] * (t); \
77 (u)[2] = (p)[2] + (v)[2] * (t); \
80 /*---------------------------------------------------------------------------*/
83 void v_nrm(float *, const float *);
84 void v_crs(float *, const float *, const float *);
86 void m_cpy(float *, const float *);
87 void m_xps(float *, const float *);
88 int m_inv(float *, const float *);
90 void m_ident(float *);
91 void m_basis(float *, const float *,
95 void m_xlt(float *, const float *);
96 void m_scl(float *, const float *);
97 void m_rot(float *, const float *, float);
99 void m_mult(float *, const float *, const float *);
100 void m_pxfm(float *, const float *, const float *);
101 void m_vxfm(float *, const float *, const float *);