109#define _USE_MATH_DEFINES 1
128# define M_1_2PI 0.159154943091895335768883763372514362
131# define M_1_PI 0.318309886183790671537767526745028724
134# define M_2_PI 0.636619772367581343075535053490057448
137# define M_2_SQRTPI 1.12837916709551257389615890312154517
140# define M_E 2.71828182845904523536028747135266250
143# define M_EULER 0.577215664901532860606512090082402431
146# define M_LOG2E 1.44269504088896340735992468100189214
149# define M_LOG10E 0.434294481903251827651128918916605082
152# define M_LN2 0.693147180559945309417232121458176568
155# define M_LN10 2.30258509299404568401799145468436421
158# define M_LNPI 1.14472988584940017414342735135305871
161# define M_PI 3.14159265358979323846264338327950288
164# define M_2PI 6.28318530717958647692528676655900576
167# define M_PI_2 1.57079632679489661923132169163975144
170# define M_PI_3 1.04719755119659774615421446109316763
173# define M_PI_4 0.785398163397448309615660845819875721
176# define M_SQRT1_2 0.707106781186547524400844362104849039
179# define M_SQRT2 1.41421356237309504880168872420969808
182# define M_SQRT3 1.73205080756887729352744634150587237
185# define M_SQRTPI 1.77245385090551602729816748334114518
189# define DEG2RAD 0.0174532925199432957692369076848861271
192# define RAD2DEG 57.2957795130823208767981548141051703
228# define MAX_FASTF 1.0e37
229# define SQRT_MAX_FASTF 1.0e18
230# define SMALL_FASTF 1.0e-37
231# define SQRT_SMALL_FASTF 1.0e-18
234# define MAX_FASTF 1.0e73
235# define SQRT_MAX_FASTF 1.0e36
236# define SMALL_FASTF 1.0e-77
238# define SQRT_SMALL_FASTF 1.0e-40
240# define SQRT_SMALL_FASTF 1.0e-39
245#define SMALL SQRT_SMALL_FASTF
259# define INFINITY ((fastf_t)DBL_MAX)
260# elif defined(HUGE_VAL)
261# define INFINITY ((fastf_t)HUGE_VAL)
262# elif defined(MAXDOUBLE)
263# define INFINITY ((fastf_t)MAXDOUBLE)
265# define INFINITY ((fastf_t)HUGE)
267# elif defined(FLT_MAX)
268# define INFINITY ((fastf_t)FLT_MAX)
269# elif defined(HUGE_VALF)
270# define INFINITY ((fastf_t)HUGE_VALF)
271# elif defined(MAXFLOAT)
272# define INFINITY ((fastf_t)MAXFLOAT)
277# define INFINITY ((fastf_t)1.0e38)
284# define VDIVIDE_TOL (1.0e-10)
285# define VUNITIZE_TOL (1.0e-7)
288# define VDIVIDE_TOL (DBL_EPSILON)
290# define VDIVIDE_TOL (1.0e-20)
293# define VUNITIZE_TOL (FLT_EPSILON)
295# define VUNITIZE_TOL (1.0e-15)
301#define ELEMENTS_PER_VECT2D 2
304#define ELEMENTS_PER_POINT2D 2
307#define ELEMENTS_PER_VECT 3
310#define ELEMENTS_PER_POINT 3
313#define ELEMENTS_PER_HVECT 4
316#define ELEMENTS_PER_HPOINT 4
319#define ELEMENTS_PER_PLANE 4
322#define ELEMENTS_PER_MAT (ELEMENTS_PER_PLANE*ELEMENTS_PER_PLANE)
422#define INVALID(n) (!((n) > -INFINITY && (n) < INFINITY))
428#define VINVALID(v) (INVALID((v)[X]) || INVALID((v)[Y]) || INVALID((v)[Z]))
434#define V2INVALID(v) (INVALID((v)[X]) || INVALID((v)[Y]))
440#define HINVALID(v) (INVALID((v)[X]) || INVALID((v)[Y]) || INVALID((v)[Z]) || INVALID((v)[W]))
446#ifdef KEITH_WANTS_THIS
458# define NEAR_ZERO(val, epsilon) (!(((val) < -epsilon) || ((val) > epsilon)))
459# define NEAR_ZERO(val, epsilon) (!(((val) < -epsilon)) && !(((val) > epsilon)))
461# define NEAR_ZERO(val, epsilon) (((val) > -epsilon) && ((val) < epsilon))
468#define VNEAR_ZERO(v, tol) \
469 (NEAR_ZERO(v[X], tol) \
470 && NEAR_ZERO(v[Y], tol) \
471 && NEAR_ZERO(v[Z], tol))
477#define V2NEAR_ZERO(v, tol) (NEAR_ZERO(v[X], tol) && NEAR_ZERO(v[Y], tol))
483#define HNEAR_ZERO(v, tol) \
484 (NEAR_ZERO(v[X], tol) \
485 && NEAR_ZERO(v[Y], tol) \
486 && NEAR_ZERO(v[Z], tol) \
487 && NEAR_ZERO(h[W], tol))
494#define ZERO(_a) NEAR_ZERO((_a), SMALL_FASTF)
500#define VZERO(_a) VNEAR_ZERO((_a), SMALL_FASTF)
506#define V2ZERO(_a) V2NEAR_ZERO((_a), SMALL_FASTF)
512#define HZERO(_a) HNEAR_ZERO((_a), SMALL_FASTF)
519#define NEAR_EQUAL(_a, _b, _tol) NEAR_ZERO((_a) - (_b), (_tol))
525#define VNEAR_EQUAL(_a, _b, _tol) \
526 (NEAR_EQUAL((_a)[X], (_b)[X], (_tol)) \
527 && NEAR_EQUAL((_a)[Y], (_b)[Y], (_tol)) \
528 && NEAR_EQUAL((_a)[Z], (_b)[Z], (_tol)))
534#define V2NEAR_EQUAL(a, b, tol) \
535 (NEAR_EQUAL((a)[X], (b)[X], tol) \
536 && NEAR_EQUAL((a)[Y], (b)[Y], tol))
542#define HNEAR_EQUAL(_a, _b, _tol) \
543 (NEAR_EQUAL((_a)[X], (_b)[X], (_tol)) \
544 && NEAR_EQUAL((_a)[Y], (_b)[Y], (_tol)) \
545 && NEAR_EQUAL((_a)[Z], (_b)[Z], (_tol)) \
546 && NEAR_EQUAL((_a)[W], (_b)[W], (_tol)))
552#define EQUAL(_a, _b) NEAR_EQUAL((_a), (_b), SMALL_FASTF)
559#define VEQUAL(_a, _b) VNEAR_EQUAL((_a), (_b), SMALL_FASTF)
565#define V2EQUAL(_a, _b) V2NEAR_EQUAL((_a), (_b), SMALL_FASTF)
571#define HEQUAL(_a, _b) HNEAR_EQUAL((_a), (_b), SMALL_FASTF)
575#define DIST_PNT_PLANE(_pt, _pl) (VDOT(_pt, _pl) - (_pl)[W])
578#define DIST_PNT_PNT_SQ(_a, _b) \
579 ((_a)[X]-(_b)[X])*((_a)[X]-(_b)[X]) + \
580 ((_a)[Y]-(_b)[Y])*((_a)[Y]-(_b)[Y]) + \
581 ((_a)[Z]-(_b)[Z])*((_a)[Z]-(_b)[Z])
582#define DIST_PNT_PNT(_a, _b) sqrt(DIST_PNT_PNT_SQ(_a, _b))
585#define DIST_PNT2_PNT2_SQ(_a, _b) \
586 ((_a)[X]-(_b)[X])*((_a)[X]-(_b)[X]) + \
587 ((_a)[Y]-(_b)[Y])*((_a)[Y]-(_b)[Y])
588#define DIST_PNT2_PNT2(_a, _b) sqrt(DIST_PNT2_PNT2_SQ(_a, _b))
591#define MAT_DELTAS(_m, _x, _y, _z) do { \
598#define MAT_DELTAS_VEC(_m, _v) \
599 MAT_DELTAS(_m, (_v)[X], (_v)[Y], (_v)[Z])
605#define MAT_DELTAS_VEC_NEG(_m, _v) \
606 MAT_DELTAS(_m, -(_v)[X], -(_v)[Y], -(_v)[Z])
609#define MAT_DELTAS_GET(_v, _m) do { \
610 (_v)[X] = (_m)[MDX]; \
611 (_v)[Y] = (_m)[MDY]; \
612 (_v)[Z] = (_m)[MDZ]; \
619#define MAT_DELTAS_GET_NEG(_v, _m) do { \
620 (_v)[X] = -(_m)[MDX]; \
621 (_v)[Y] = -(_m)[MDY]; \
622 (_v)[Z] = -(_m)[MDZ]; \
629#define MAT_DELTAS_ADD(_m, _x, _y, _z) do { \
639#define MAT_DELTAS_ADD_VEC(_m, _v) do { \
640 (_m)[MDX] += (_v)[X]; \
641 (_m)[MDY] += (_v)[Y]; \
642 (_m)[MDZ] += (_v)[Z]; \
649#define MAT_DELTAS_SUB(_m, _x, _y, _z) do { \
659#define MAT_DELTAS_SUB_VEC(_m, _v) do { \
660 (_m)[MDX] -= (_v)[X]; \
661 (_m)[MDY] -= (_v)[Y]; \
662 (_m)[MDZ] -= (_v)[Z]; \
669#define MAT_DELTAS_MUL(_m, _x, _y, _z) do { \
679#define MAT_DELTAS_MUL_VEC(_m, _v) do { \
680 (_m)[MDX] *= (_v)[X]; \
681 (_m)[MDY] *= (_v)[Y]; \
682 (_m)[MDZ] *= (_v)[Z]; \
686#define MAT_SCALE(_m, _x, _y, _z) do { \
693#define MAT_SCALE_VEC(_m, _v) do { \
694 (_m)[MSX] = (_v)[X]; \
695 (_m)[MSY] = (_v)[Y]; \
696 (_m)[MSZ] = (_v)[Z]; \
700#define MAT_SCALE_ALL(_m, _s) (_m)[MSA] = (_s)
703#define MAT_SCALE_ADD(_m, _x, _y, _z) do { \
710#define MAT_SCALE_ADD_VEC(_m, _v) do { \
711 (_m)[MSX] += (_v)[X]; \
712 (_m)[MSY] += (_v)[Y]; \
713 (_m)[MSZ] += (_v)[Z]; \
717#define MAT_SCALE_SUB(_m, _x, _y, _z) do { \
727#define MAT_SCALE_SUB_VEC(_m, _v) do { \
728 (_m)[MSX] -= (_v)[X]; \
729 (_m)[MSY] -= (_v)[Y]; \
730 (_m)[MSZ] -= (_v)[Z]; \
734#define MAT_SCALE_MUL(_m, _x, _y, _z) do { \
741#define MAT_SCALE_MUL_VEC(_m, _v) do { \
742 (_m)[MSX] *= (_v)[X]; \
743 (_m)[MSY] *= (_v)[Y]; \
744 (_m)[MSZ] *= (_v)[Z]; \
755#define MAT_ZERO(m) do { \
756 (m)[0] = (m)[1] = (m)[2] = (m)[3] = \
757 (m)[4] = (m)[5] = (m)[6] = (m)[7] = \
758 (m)[8] = (m)[9] = (m)[10] = (m)[11] = \
759 (m)[12] = (m)[13] = (m)[14] = (m)[15] = 0.0; \
763#define MAT_IDN(m) do { \
764 (m)[1] = (m)[2] = (m)[3] = (m)[4] = \
765 (m)[6] = (m)[7] = (m)[8] = (m)[9] = \
766 (m)[11] = (m)[12] = (m)[13] = (m)[14] = 0.0; \
767 (m)[0] = (m)[5] = (m)[10] = (m)[15] = 1.0; \
776#define MAT_TRANSPOSE(t, m) do { \
796#define MAT_COPY(c, m) do { \
816#define VSET(o, a, b, c) do { \
823#define V2SET(o, a, b) do { \
829#define HSET(o, a, b, c, d) do { \
838#define VSETALL(v, s) do { \
839 (v)[X] = (v)[Y] = (v)[Z] = (s); \
843#define V2SETALL(v, s) do { \
844 (v)[X] = (v)[Y] = (s); \
848#define HSETALL(v, s) do { \
849 (v)[X] = (v)[Y] = (v)[Z] = (v)[W] = (s); \
854#define VSETALLN(v, s, n) do { \
856 for (_j=0; _j < (size_t)(n); _j++) v[_j]=(s); \
861#define VMOVE(o, v) do { \
868#define V2MOVE(o, v) do { \
874#define HMOVE(o, v) do { \
882#define VMOVEN(o, v, n) do { \
884 for (_vmove = 0; _vmove < (size_t)(n); _vmove++) { \
885 (o)[_vmove] = (v)[_vmove]; \
895#define VREVERSE(o, v) do { \
906#define V2REVERSE(o, v) do { \
917#define HREVERSE(o, v) do { \
925#define VADD2(o, a, b) do { \
926 (o)[X] = (a)[X] + (b)[X]; \
927 (o)[Y] = (a)[Y] + (b)[Y]; \
928 (o)[Z] = (a)[Z] + (b)[Z]; \
932#define V2ADD2(o, a, b) do { \
933 (o)[X] = (a)[X] + (b)[X]; \
934 (o)[Y] = (a)[Y] + (b)[Y]; \
938#define HADD2(o, a, b) do { \
939 (o)[X] = (a)[X] + (b)[X]; \
940 (o)[Y] = (a)[Y] + (b)[Y]; \
941 (o)[Z] = (a)[Z] + (b)[Z]; \
942 (o)[W] = (a)[W] + (b)[W]; \
949#define VADD2N(o, a, b, n) do { \
951 for (_vadd2 = 0; _vadd2 < (size_t)(n); _vadd2++) { \
952 (o)[_vadd2] = (a)[_vadd2] + (b)[_vadd2]; \
961#define VSUB2(o, a, b) do { \
962 (o)[X] = (a)[X] - (b)[X]; \
963 (o)[Y] = (a)[Y] - (b)[Y]; \
964 (o)[Z] = (a)[Z] - (b)[Z]; \
971#define V2SUB2(o, a, b) do { \
972 (o)[X] = (a)[X] - (b)[X]; \
973 (o)[Y] = (a)[Y] - (b)[Y]; \
980#define HSUB2(o, a, b) do { \
981 (o)[X] = (a)[X] - (b)[X]; \
982 (o)[Y] = (a)[Y] - (b)[Y]; \
983 (o)[Z] = (a)[Z] - (b)[Z]; \
984 (o)[W] = (a)[W] - (b)[W]; \
991#define VSUB2N(o, a, b, n) do { \
993 for (_vsub2 = 0; _vsub2 < (size_t)(n); _vsub2++) { \
994 (o)[_vsub2] = (a)[_vsub2] - (b)[_vsub2]; \
1000#define VSUB3(o, a, b, c) do { \
1001 (o)[X] = (a)[X] - (b)[X] - (c)[X]; \
1002 (o)[Y] = (a)[Y] - (b)[Y] - (c)[Y]; \
1003 (o)[Z] = (a)[Z] - (b)[Z] - (c)[Z]; \
1007#define V2SUB3(o, a, b, c) do { \
1008 (o)[X] = (a)[X] - (b)[X] - (c)[X]; \
1009 (o)[Y] = (a)[Y] - (b)[Y] - (c)[Y]; \
1013#define HSUB3(o, a, b, c) do { \
1014 (o)[X] = (a)[X] - (b)[X] - (c)[X]; \
1015 (o)[Y] = (a)[Y] - (b)[Y] - (c)[Y]; \
1016 (o)[Z] = (a)[Z] - (b)[Z] - (c)[Z]; \
1017 (o)[W] = (a)[W] - (b)[W] - (c)[W]; \
1021#define VSUB3N(o, a, b, c, n) do { \
1023 for (_vsub3 = 0; _vsub3 < (size_t)(n); _vsub3++) { \
1024 (o)[_vsub3] = (a)[_vsub3] - (b)[_vsub3] - (c)[_vsub3]; \
1030#define VADD3(o, a, b, c) do { \
1031 (o)[X] = (a)[X] + (b)[X] + (c)[X]; \
1032 (o)[Y] = (a)[Y] + (b)[Y] + (c)[Y]; \
1033 (o)[Z] = (a)[Z] + (b)[Z] + (c)[Z]; \
1037#define V2ADD3(o, a, b, c) do { \
1038 (o)[X] = (a)[X] + (b)[X] + (c)[X]; \
1039 (o)[Y] = (a)[Y] + (b)[Y] + (c)[Y]; \
1043#define HADD3(o, a, b, c) do { \
1044 (o)[X] = (a)[X] + (b)[X] + (c)[X]; \
1045 (o)[Y] = (a)[Y] + (b)[Y] + (c)[Y]; \
1046 (o)[Z] = (a)[Z] + (b)[Z] + (c)[Z]; \
1047 (o)[W] = (a)[W] + (b)[W] + (c)[W]; \
1054#define VADD3N(o, a, b, c, n) do { \
1056 for (_vadd3 = 0; _vadd3 < (size_t)(n); _vadd3++) { \
1057 (o)[_vadd3] = (a)[_vadd3] + (b)[_vadd3] + (c)[_vadd3]; \
1066#define VADD4(o, a, b, c, d) do { \
1067 (o)[X] = (a)[X] + (b)[X] + (c)[X] + (d)[X]; \
1068 (o)[Y] = (a)[Y] + (b)[Y] + (c)[Y] + (d)[Y]; \
1069 (o)[Z] = (a)[Z] + (b)[Z] + (c)[Z] + (d)[Z]; \
1076#define V2ADD4(o, a, b, c, d) do { \
1077 (o)[X] = (a)[X] + (b)[X] + (c)[X] + (d)[X]; \
1078 (o)[Y] = (a)[Y] + (b)[Y] + (c)[Y] + (d)[Y]; \
1085#define HADD4(o, a, b, c, d) do { \
1086 (o)[X] = (a)[X] + (b)[X] + (c)[X] + (d)[X]; \
1087 (o)[Y] = (a)[Y] + (b)[Y] + (c)[Y] + (d)[Y]; \
1088 (o)[Z] = (a)[Z] + (b)[Z] + (c)[Z] + (d)[Z]; \
1089 (o)[W] = (a)[W] + (b)[W] + (c)[W] + (d)[W]; \
1096#define VADD4N(o, a, b, c, d, n) do { \
1098 for (_vadd4 = 0; _vadd4 < (size_t)(n); _vadd4++) { \
1099 (o)[_vadd4] = (a)[_vadd4] + (b)[_vadd4] + (c)[_vadd4] + (d)[_vadd4]; \
1105#define VSCALE(o, v, s) do { \
1106 (o)[X] = (v)[X] * (s); \
1107 (o)[Y] = (v)[Y] * (s); \
1108 (o)[Z] = (v)[Z] * (s); \
1112#define V2SCALE(o, v, s) do { \
1113 (o)[X] = (v)[X] * (s); \
1114 (o)[Y] = (v)[Y] * (s); \
1118#define HSCALE(o, v, s) do { \
1119 (o)[X] = (v)[X] * (s); \
1120 (o)[Y] = (v)[Y] * (s); \
1121 (o)[Z] = (v)[Z] * (s); \
1122 (o)[W] = (v)[W] * (s); \
1129#define VSCALEN(o, v, s, n) do { \
1131 for (_vscale = 0; _vscale < (size_t)(n); _vscale++) { \
1132 (o)[_vscale] = (v)[_vscale] * (s); \
1137#define VUNITIZE(v) do { \
1138 double _f = MAGSQ(v); \
1139 if (! NEAR_EQUAL(_f, 1.0, VUNITIZE_TOL)) { \
1141 if (_f < VDIVIDE_TOL) { \
1142 VSETALL((v), 0.0); \
1145 (v)[X] *= _f; (v)[Y] *= _f; (v)[Z] *= _f; \
1151#define V2UNITIZE(v) do { \
1152 double _f = MAG2SQ(v); \
1153 if (! NEAR_EQUAL(_f, 1.0, VUNITIZE_TOL)) { \
1155 if (_f < VDIVIDE_TOL) { \
1156 V2SETALL((v), 0.0); \
1159 (v)[X] *= _f; (v)[Y] *= _f; \
1168#define VADD2SCALE(o, a, b, s) do { \
1169 (o)[X] = ((a)[X] + (b)[X]) * (s); \
1170 (o)[Y] = ((a)[Y] + (b)[Y]) * (s); \
1171 (o)[Z] = ((a)[Z] + (b)[Z]) * (s); \
1178#define VADD2SCALEN(o, a, b, s, n) do { \
1179 size_t _vadd2scale; \
1180 for (_vadd2scale = 0; \
1181 _vadd2scale < (size_t)(n); \
1183 (o)[_vadd2scale] = ((a)[_vadd2scale] + (b)[_vadd2scale]) * (s); \
1191#define VSUB2SCALE(o, a, b, s) do { \
1192 (o)[X] = ((a)[X] - (b)[X]) * (s); \
1193 (o)[Y] = ((a)[Y] - (b)[Y]) * (s); \
1194 (o)[Z] = ((a)[Z] - (b)[Z]) * (s); \
1201#define VSUB2SCALEN(o, a, b, s, n) do { \
1202 size_t _vsub2scale; \
1203 for (_vsub2scale = 0; \
1204 _vsub2scale < (size_t)(n); \
1206 (o)[_vsub2scale] = ((a)[_vsub2scale] - (b)[_vsub2scale]) * (s); \
1216#define VCOMB3(o, a, b, c, d, e, f) do { \
1217 (o)[X] = (a) * (b)[X] + (c) * (d)[X] + (e) * (f)[X]; \
1218 (o)[Y] = (a) * (b)[Y] + (c) * (d)[Y] + (e) * (f)[Y]; \
1219 (o)[Z] = (a) * (b)[Z] + (c) * (d)[Z] + (e) * (f)[Z]; \
1228#define VCOMB3N(o, a, b, c, d, e, f, n) do { \
1231 _vcomb3 < (size_t)(n); \
1233 (o)[_vcomb3] = (a) * (b)[_vcomb3] + (c) * (d)[_vcomb3] + (e) * (f)[_vcomb3]; \
1240#define VCOMB2(o, sa, va, sb, vb) do { \
1241 (o)[X] = (sa) * (va)[X] + (sb) * (vb)[X]; \
1242 (o)[Y] = (sa) * (va)[Y] + (sb) * (vb)[Y]; \
1243 (o)[Z] = (sa) * (va)[Z] + (sb) * (vb)[Z]; \
1250#define VCOMB2N(o, sa, a, sb, b, n) do { \
1253 _vcomb2 < (size_t)(n); \
1255 (o)[_vcomb2] = (sa) * (va)[_vcomb2] + (sb) * (vb)[_vcomb2]; \
1262#define VJOIN4(a, b, c, d, e, f, g, h, i, j) do { \
1263 (a)[X] = (b)[X] + (c)*(d)[X] + (e)*(f)[X] + (g)*(h)[X] + (i)*(j)[X]; \
1264 (a)[Y] = (b)[Y] + (c)*(d)[Y] + (e)*(f)[Y] + (g)*(h)[Y] + (i)*(j)[Y]; \
1265 (a)[Z] = (b)[Z] + (c)*(d)[Z] + (e)*(f)[Z] + (g)*(h)[Z] + (i)*(j)[Z]; \
1271#define VJOIN3(o, a, sb, b, sc, c, sd, d) do { \
1272 (o)[X] = (a)[X] + (sb)*(b)[X] + (sc)*(c)[X] + (sd)*(d)[X]; \
1273 (o)[Y] = (a)[Y] + (sb)*(b)[Y] + (sc)*(c)[Y] + (sd)*(d)[Y]; \
1274 (o)[Z] = (a)[Z] + (sb)*(b)[Z] + (sc)*(c)[Z] + (sd)*(d)[Z]; \
1284#define VJOIN2(o, a, sb, b, sc, c) do { \
1285 (o)[X] = (a)[X] + (sb) * (b)[X] + (sc) * (c)[X]; \
1286 (o)[Y] = (a)[Y] + (sb) * (b)[Y] + (sc) * (c)[Y]; \
1287 (o)[Z] = (a)[Z] + (sb) * (b)[Z] + (sc) * (c)[Z]; \
1296#define V2JOIN2(o, a, sb, b, sc, c) do { \
1297 (o)[X] = (a)[X] + (sb) * (b)[X] + (sc) * (c)[X]; \
1298 (o)[Y] = (a)[Y] + (sb) * (b)[Y] + (sc) * (c)[Y]; \
1307#define HJOIN2(o, a, sb, b, sc, c) do { \
1308 (o)[X] = (a)[X] + (sb) * (b)[X] + (sc) * (c)[X]; \
1309 (o)[Y] = (a)[Y] + (sb) * (b)[Y] + (sc) * (c)[Y]; \
1310 (o)[Z] = (a)[Z] + (sb) * (b)[Z] + (sc) * (c)[Z]; \
1311 (o)[W] = (a)[W] + (sb) * (b)[W] + (sc) * (c)[W]; \
1314#define VJOIN2N(o, a, sb, b, sc, c, n) do { \
1317 _vjoin2 < (size_t)(n); \
1319 (o)[_vjoin2] = (a)[_vjoin2] + (sb) * (b)[_vjoin2] + (sc) * (c)[_vjoin2]; \
1331#define VJOIN1(o, a, sb, b) do { \
1332 (o)[X] = (a)[X] + (sb) * (b)[X]; \
1333 (o)[Y] = (a)[Y] + (sb) * (b)[Y]; \
1334 (o)[Z] = (a)[Z] + (sb) * (b)[Z]; \
1344#define V2JOIN1(o, a, sb, b) do { \
1345 (o)[X] = (a)[X] + (sb) * (b)[X]; \
1346 (o)[Y] = (a)[Y] + (sb) * (b)[Y]; \
1356#define HJOIN1(o, a, sb, b) do { \
1357 (o)[X] = (a)[X] + (sb) * (b)[X]; \
1358 (o)[Y] = (a)[Y] + (sb) * (b)[Y]; \
1359 (o)[Z] = (a)[Z] + (sb) * (b)[Z]; \
1360 (o)[W] = (a)[W] + (sb) * (b)[W]; \
1370#define VJOIN1N(o, a, sb, b, n) do { \
1373 _vjoin1 < (size_t)(n); \
1375 (o)[_vjoin1] = (a)[_vjoin1] + (sb) * (b)[_vjoin1]; \
1385#define VBLEND2(o, sa, a, sb, b) do { \
1386 (o)[X] = (sa) * (a)[X] + (sb) * (b)[X]; \
1387 (o)[Y] = (sa) * (a)[Y] + (sb) * (b)[Y]; \
1388 (o)[Z] = (sa) * (a)[Z] + (sb) * (b)[Z]; \
1396#define VBLEND2N(o, sa, a, sb, b, n) do { \
1398 for (_vblend2 = 0; \
1399 _vblend2 < (size_t)(n); \
1401 (b)[_vblend2] = (sa) * (a)[_vblend2] + (sb) * (b)[_vblend2]; \
1413#define VPROJECT(a, b, c, d) do { \
1414 VSCALE(c, b, VDOT(a, b) / VDOT(b, b)); \
1419#define MAGSQ(v) ((v)[X]*(v)[X] + (v)[Y]*(v)[Y] + (v)[Z]*(v)[Z])
1420#define MAG2SQ(v) ((v)[X]*(v)[X] + (v)[Y]*(v)[Y])
1427#define MAGNITUDE(v) sqrt(MAGSQ(v))
1433#define MAGNITUDE2(v) sqrt(MAG2SQ(v))
1450#define VCROSS(o, a, b) do { \
1451 (o)[X] = (a)[Y] * (b)[Z] - (a)[Z] * (b)[Y]; \
1452 (o)[Y] = (a)[Z] * (b)[X] - (a)[X] * (b)[Z]; \
1453 (o)[Z] = (a)[X] * (b)[Y] - (a)[Y] * (b)[X]; \
1461#define V2CROSS(a, b) ((a)[X] * (b)[Y] - (a)[Y] * (b)[X])
1466#define HCROSS(a, b, c)
1470#define VDOT(a, b) ((a)[X]*(b)[X] + (a)[Y]*(b)[Y] + (a)[Z]*(b)[Z])
1472#define V2DOT(a, b) ((a)[X]*(b)[X] + (a)[Y]*(b)[Y])
1474#define HDOT(a, b) ((a)[X]*(b)[X] + (a)[Y]*(b)[Y] + (a)[Z]*(b)[Z] + (a)[W]*(b)[W])
1486#define VLERP(o, a, b, t) do { \
1487 (o)[X] = (a)[X] * (1 - (t)) + (b)[X] * (t); \
1488 (o)[Y] = (a)[Y] * (1 - (t)) + (b)[Y] * (t); \
1489 (o)[Z] = (a)[Z] * (1 - (t)) + (b)[Z] * (t); \
1501#define V2LERP(o, a, b, t) do { \
1502 (o)[X] = (a)[X] * (1 - (t)) + (b)[X] * (t); \
1503 (o)[Y] = (a)[Y] * (1 - (t)) + (b)[Y] * (t); \
1515#define HLERP(o, a, b, t) do { \
1516 (o)[X] = (a)[X] * (1 - (t)) + (b)[X] * (t); \
1517 (o)[Y] = (a)[Y] * (1 - (t)) + (b)[Y] * (t); \
1518 (o)[Z] = (a)[Z] * (1 - (t)) + (b)[Z] * (t); \
1519 (o)[W] = (a)[W] * (1 - (t)) + (b)[W] * (t); \
1527#define VSUB2DOT(_pt2, _pt, _vec) (\
1528 ((_pt2)[X] - (_pt)[X]) * (_vec)[X] + \
1529 ((_pt2)[Y] - (_pt)[Y]) * (_vec)[Y] + \
1530 ((_pt2)[Z] - (_pt)[Z]) * (_vec)[Z])
1536#define V2ARGS(a) (a)[X], (a)[Y]
1537#define V3ARGS(a) (a)[X], (a)[Y], (a)[Z]
1538#define V4ARGS(a) (a)[X], (a)[Y], (a)[Z], (a)[W]
1549#define INTCLAMP(_a) (NEAR_EQUAL((_a), rint(_a), VUNITIZE_TOL) ? rint(_a) : (_a))
1552#define VINTCLAMP(_v) do { \
1553 (_v)[X] = INTCLAMP((_v)[X]); \
1554 (_v)[Y] = INTCLAMP((_v)[Y]); \
1555 (_v)[Z] = INTCLAMP((_v)[Z]); \
1559#define V2INTCLAMP(_v) do { \
1560 (_v)[X] = INTCLAMP((_v)[X]); \
1561 (_v)[Y] = INTCLAMP((_v)[Y]); \
1565#define HINTCLAMP(_v) do { \
1567 (_v)[W] = INTCLAMP((_v)[W]); \
1572#define V2INTCLAMPARGS(a) INTCLAMP((a)[X]), INTCLAMP((a)[Y])
1574#define V3INTCLAMPARGS(a) INTCLAMP((a)[X]), INTCLAMP((a)[Y]), INTCLAMP((a)[Z])
1576#define V4INTCLAMPARGS(a) INTCLAMP((a)[X]), INTCLAMP((a)[Y]), INTCLAMP((a)[Z]), INTCLAMP((a)[W])
1579#define V2PRINT(a, b) \
1580 fprintf(stderr, "%s (%.6f, %.6g)\n", a, V2ARGS(b));
1581#define VPRINT(a, b) \
1582 fprintf(stderr, "%s (%.6f, %.6f, %.6f)\n", a, V3ARGS(b));
1583#define HPRINT(a, b) \
1584 fprintf(stderr, "%s (%.6f, %.6f, %.6f, %.6f)\n", a, V4ARGS(b));
1591#define V2INTCLAMPPRINT(a, b) \
1592 fprintf(stderr, "%s (%g, %g)\n", a, V2INTCLAMPARGS(b));
1593#define VINTCLAMPPRINT(a, b) \
1594 fprintf(stderr, "%s (%g, %g, %g)\n", a, V3INTCLAMPARGS(b));
1595#define HINTCLAMPPRINT(a, b) \
1596 fprintf(stderr, "%s (%g, %g, %g, %g)\n", a, V4INTCLAMPARGS(b));
1600#define VELMUL(o, a, b) do { \
1601 (o)[X] = (a)[X] * (b)[X]; \
1602 (o)[Y] = (a)[Y] * (b)[Y]; \
1603 (o)[Z] = (a)[Z] * (b)[Z]; \
1606#define VELMUL3(o, a, b, c) do { \
1607 (o)[X] = (a)[X] * (b)[X] * (c)[X]; \
1608 (o)[Y] = (a)[Y] * (b)[Y] * (c)[Y]; \
1609 (o)[Z] = (a)[Z] * (b)[Z] * (c)[Z]; \
1613#define VELDIV(o, a, b) do { \
1614 (o)[X] = (a)[X] / (b)[X]; \
1615 (o)[Y] = (a)[Y] / (b)[Y]; \
1616 (o)[Z] = (a)[Z] / (b)[Z]; \
1623#define VINVDIR(_inv, _dir) do { \
1624 if ((_dir)[X] < -SQRT_SMALL_FASTF || (_dir)[X] > SQRT_SMALL_FASTF) { \
1625 (_inv)[X]=1.0/(_dir)[X]; \
1628 (_inv)[X] = INFINITY; \
1630 if ((_dir)[Y] < -SQRT_SMALL_FASTF || (_dir)[Y] > SQRT_SMALL_FASTF) { \
1631 (_inv)[Y]=1.0/(_dir)[Y]; \
1634 (_inv)[Y] = INFINITY; \
1636 if ((_dir)[Z] < -SQRT_SMALL_FASTF || (_dir)[Z] > SQRT_SMALL_FASTF) { \
1637 (_inv)[Z]=1.0/(_dir)[Z]; \
1640 (_inv)[Z] = INFINITY; \
1648#define MAT3X3VEC(o, mat, vec) do { \
1649 (o)[X] = (mat)[X]*(vec)[X]+(mat)[Y]*(vec)[Y] + (mat)[ 2]*(vec)[Z]; \
1650 (o)[Y] = (mat)[4]*(vec)[X]+(mat)[5]*(vec)[Y] + (mat)[ 6]*(vec)[Z]; \
1651 (o)[Z] = (mat)[8]*(vec)[X]+(mat)[9]*(vec)[Y] + (mat)[10]*(vec)[Z]; \
1655#define VEC3X3MAT(o, i, m) do { \
1656 (o)[X] = (i)[X]*(m)[X] + (i)[Y]*(m)[4] + (i)[Z]*(m)[8]; \
1657 (o)[Y] = (i)[X]*(m)[1] + (i)[Y]*(m)[5] + (i)[Z]*(m)[9]; \
1658 (o)[Z] = (i)[X]*(m)[2] + (i)[Y]*(m)[6] + (i)[Z]*(m)[10]; \
1662#define MAT3X2VEC(o, mat, vec) do { \
1663 (o)[X] = (mat)[0]*(vec)[X] + (mat)[Y]*(vec)[Y]; \
1664 (o)[Y] = (mat)[4]*(vec)[X] + (mat)[5]*(vec)[Y]; \
1665 (o)[Z] = (mat)[8]*(vec)[X] + (mat)[9]*(vec)[Y]; \
1669#define VEC2X3MAT(o, i, m) do { \
1670 (o)[X] = (i)[X]*(m)[0] + (i)[Y]*(m)[4]; \
1671 (o)[Y] = (i)[X]*(m)[1] + (i)[Y]*(m)[5]; \
1672 (o)[Z] = (i)[X]*(m)[2] + (i)[Y]*(m)[6]; \
1679#define MAT4X3PNT(o, m, i) do { \
1681 _f = 1.0/((m)[12]*(i)[X] + (m)[13]*(i)[Y] + (m)[14]*(i)[Z] + (m)[15]); \
1682 (o)[X]=((m)[0]*(i)[X] + (m)[1]*(i)[Y] + (m)[ 2]*(i)[Z] + (m)[3]) * _f; \
1683 (o)[Y]=((m)[4]*(i)[X] + (m)[5]*(i)[Y] + (m)[ 6]*(i)[Z] + (m)[7]) * _f; \
1684 (o)[Z]=((m)[8]*(i)[X] + (m)[9]*(i)[Y] + (m)[10]*(i)[Z] + (m)[11])* _f; \
1691#define PNT3X4MAT(o, i, m) do { \
1693 _f = 1.0/((i)[X]*(m)[3] + (i)[Y]*(m)[7] + (i)[Z]*(m)[11] + (m)[15]); \
1694 (o)[X]=((i)[X]*(m)[0] + (i)[Y]*(m)[4] + (i)[Z]*(m)[8] + (m)[12]) * _f; \
1695 (o)[Y]=((i)[X]*(m)[1] + (i)[Y]*(m)[5] + (i)[Z]*(m)[9] + (m)[13]) * _f; \
1696 (o)[Z]=((i)[X]*(m)[2] + (i)[Y]*(m)[6] + (i)[Z]*(m)[10] + (m)[14])* _f; \
1703#define MAT4X4PNT(o, m, i) do { \
1704 (o)[X]=(m)[ 0]*(i)[X] + (m)[ 1]*(i)[Y] + (m)[ 2]*(i)[Z] + (m)[ 3]*(i)[W]; \
1705 (o)[Y]=(m)[ 4]*(i)[X] + (m)[ 5]*(i)[Y] + (m)[ 6]*(i)[Z] + (m)[ 7]*(i)[W]; \
1706 (o)[Z]=(m)[ 8]*(i)[X] + (m)[ 9]*(i)[Y] + (m)[10]*(i)[Z] + (m)[11]*(i)[W]; \
1707 (o)[W]=(m)[12]*(i)[X] + (m)[13]*(i)[Y] + (m)[14]*(i)[Z] + (m)[15]*(i)[W]; \
1715#define MAT4X3VEC(o, m, i) do { \
1717 _f = 1.0/((m)[15]); \
1718 (o)[X] = ((m)[0]*(i)[X] + (m)[1]*(i)[Y] + (m)[ 2]*(i)[Z]) * _f; \
1719 (o)[Y] = ((m)[4]*(i)[X] + (m)[5]*(i)[Y] + (m)[ 6]*(i)[Z]) * _f; \
1720 (o)[Z] = ((m)[8]*(i)[X] + (m)[9]*(i)[Y] + (m)[10]*(i)[Z]) * _f; \
1723#define MAT4XSCALOR(o, m, i) do { \
1724 (o) = (i) / (m)[15]; \
1731#define VEC3X4MAT(o, i, m) do { \
1733 _f = 1.0/((m)[15]); \
1734 (o)[X] = ((i)[X]*(m)[0] + (i)[Y]*(m)[4] + (i)[Z]*(m)[8]) * _f; \
1735 (o)[Y] = ((i)[X]*(m)[1] + (i)[Y]*(m)[5] + (i)[Z]*(m)[9]) * _f; \
1736 (o)[Z] = ((i)[X]*(m)[2] + (i)[Y]*(m)[6] + (i)[Z]*(m)[10]) * _f; \
1740#define VEC2X4MAT(o, i, m) do { \
1742 _f = 1.0/((m)[15]); \
1743 (o)[X] = ((i)[X]*(m)[0] + (i)[Y]*(m)[4]) * _f; \
1744 (o)[Y] = ((i)[X]*(m)[1] + (i)[Y]*(m)[5]) * _f; \
1745 (o)[Z] = ((i)[X]*(m)[2] + (i)[Y]*(m)[6]) * _f; \
1753#define V_MIN(r, s) if ((r) > (s)) r = (s)
1755#define V_MAX(r, s) if ((r) < (s)) r = (s)
1760#define VMIN(r, s) do { \
1761 V_MIN((r)[X], (s)[X]); V_MIN((r)[Y], (s)[Y]); V_MIN((r)[Z], (s)[Z]); \
1767#define VMAX(r, s) do { \
1768 V_MAX((r)[X], (s)[X]); V_MAX((r)[Y], (s)[Y]); V_MAX((r)[Z], (s)[Z]); \
1774#define VMINMAX(min, max, pt) do { \
1775 VMIN((min), (pt)); VMAX((max), (pt)); \
1783#define V2MIN(r, s) do { \
1784 V_MIN((r)[X], (s)[X]); V_MIN((r)[Y], (s)[Y]); \
1787#define V2MAX(r, s) do { \
1788 V_MAX((r)[X], (s)[X]); V_MAX((r)[Y], (s)[Y]); \
1791#define V2MINMAX(min, max, pt) do { \
1792 V2MIN((min), (pt)); V2MAX((max), (pt)); \
1798#define CLAMP(_v, _l, _h) V_MAX((_v), (_l)); else V_MIN((_v), (_h))
1805#define HDIVIDE(o, v) do { \
1806 (o)[X] = (v)[X] / (v)[W]; \
1807 (o)[Y] = (v)[Y] / (v)[W]; \
1808 (o)[Z] = (v)[Z] / (v)[W]; \
1834#define QUAT_FROM_ROT(q, r, x, y, z) do { \
1835 fastf_t _rot = (r) * 0.5; \
1836 QSET(q, x, y, z, cos(_rot)); \
1839 VSCALE(q, q, _rot); \
1842#define QUAT_FROM_VROT(q, r, v) do { \
1843 fastf_t _rot = (r) * 0.5; \
1846 (q)[W] = cos(_rot); \
1848 VSCALE(q, q, _rot); \
1851#define QUAT_FROM_VROT_DEG(q, r, v) \
1852 QUAT_FROM_VROT(q, ((r)*DEG2RAD), v)
1854#define QUAT_FROM_ROT_DEG(q, r, x, y, z) \
1855 QUAT_FROM_ROT(q, ((r)*DEG2RAD), x, y, z)
1862#define QSET(a, b, c, d, e) do { \
1870#define QMOVE(a, b) do { \
1878#define QADD2(a, b, c) do { \
1879 (a)[X] = (b)[X] + (c)[X]; \
1880 (a)[Y] = (b)[Y] + (c)[Y]; \
1881 (a)[Z] = (b)[Z] + (c)[Z]; \
1882 (a)[W] = (b)[W] + (c)[W]; \
1889#define QSUB2(a, b, c) do { \
1890 (a)[X] = (b)[X] - (c)[X]; \
1891 (a)[Y] = (b)[Y] - (c)[Y]; \
1892 (a)[Z] = (b)[Z] - (c)[Z]; \
1893 (a)[W] = (b)[W] - (c)[W]; \
1900#define QSCALE(a, b, c) do { \
1901 (a)[X] = (b)[X] * (c); \
1902 (a)[Y] = (b)[Y] * (c); \
1903 (a)[Z] = (b)[Z] * (c); \
1904 (a)[W] = (b)[W] * (c); \
1908#define QUNITIZE(a) do { \
1910 _f = QMAGNITUDE(a); \
1911 if (_f < VDIVIDE_TOL) _f = 0.0; else _f = 1.0/_f; \
1912 (a)[X] *= _f; (a)[Y] *= _f; (a)[Z] *= _f; (a)[W] *= _f; \
1917 ((a)[X]*(a)[X] + (a)[Y]*(a)[Y] \
1918 + (a)[Z]*(a)[Z] + (a)[W]*(a)[W])
1921#define QMAGNITUDE(a) sqrt(QMAGSQ(a))
1925 ((a)[X]*(b)[X] + (a)[Y]*(b)[Y] \
1926 + (a)[Z]*(b)[Z] + (a)[W]*(b)[W])
1935#define QMUL(a, b, c) do { \
1936 (a)[W] = (b)[W]*(c)[W] - (b)[X]*(c)[X] - (b)[Y]*(c)[Y] - (b)[Z]*(c)[Z]; \
1937 (a)[X] = (b)[W]*(c)[X] + (b)[X]*(c)[W] + (b)[Y]*(c)[Z] - (b)[Z]*(c)[Y]; \
1938 (a)[Y] = (b)[W]*(c)[Y] + (b)[Y]*(c)[W] + (b)[Z]*(c)[X] - (b)[X]*(c)[Z]; \
1939 (a)[Z] = (b)[W]*(c)[Z] + (b)[Z]*(c)[W] + (b)[X]*(c)[Y] - (b)[Y]*(c)[X]; \
1943#define QCONJUGATE(a, b) do { \
1951#define QINVERSE(a, b) do { \
1952 double _f = QMAGSQ(b); \
1953 if (_f < VDIVIDE_TOL) _f = 0.0; else _f = 1.0/_f; \
1954 (a)[X] = -(b)[X] * _f; \
1955 (a)[Y] = -(b)[Y] * _f; \
1956 (a)[Z] = -(b)[Z] * _f; \
1957 (a)[W] = (b)[W] * _f; \
1966#define QBLEND2(a, b, c, d, e) do { \
1967 (a)[X] = (b) * (c)[X] + (d) * (e)[X]; \
1968 (a)[Y] = (b) * (c)[Y] + (d) * (e)[Y]; \
1969 (a)[Z] = (b) * (c)[Z] + (d) * (e)[Z]; \
1970 (a)[W] = (b) * (c)[W] + (d) * (e)[W]; \
1983#define V3RPP_DISJOINT(_l1, _h1, _l2, _h2) \
1984 ((_l1)[X] > (_h2)[X] || (_l1)[Y] > (_h2)[Y] || (_l1)[Z] > (_h2)[Z] || \
1985 (_l2)[X] > (_h1)[X] || (_l2)[Y] > (_h1)[Y] || (_l2)[Z] > (_h1)[Z])
1991#define V3RPP_DISJOINT_TOL(_l1, _h1, _l2, _h2, _t) \
1992 ((_l1)[X] > (_h2)[X] + (_t) || \
1993 (_l1)[Y] > (_h2)[Y] + (_t) || \
1994 (_l1)[Z] > (_h2)[Z] + (_t) || \
1995 (_l2)[X] > (_h1)[X] + (_t) || \
1996 (_l2)[Y] > (_h1)[Y] + (_t) || \
1997 (_l2)[Z] > (_h1)[Z] + (_t))
2000#define V3RPP_OVERLAP(_l1, _h1, _l2, _h2) \
2001 (! ((_l1)[X] > (_h2)[X] || (_l1)[Y] > (_h2)[Y] || (_l1)[Z] > (_h2)[Z] || \
2002 (_l2)[X] > (_h1)[X] || (_l2)[Y] > (_h1)[Y] || (_l2)[Z] > (_h1)[Z]))
2008#define V3RPP_OVERLAP_TOL(_l1, _h1, _l2, _h2, _t) \
2009 (! ((_l1)[X] > (_h2)[X] + (_t) || \
2010 (_l1)[Y] > (_h2)[Y] + (_t) || \
2011 (_l1)[Z] > (_h2)[Z] + (_t) || \
2012 (_l2)[X] > (_h1)[X] + (_t) || \
2013 (_l2)[Y] > (_h1)[Y] + (_t) || \
2014 (_l2)[Z] > (_h1)[Z] + (_t)))
2021#define V3PNT_IN_RPP(_pt, _lo, _hi) (\
2022 (_pt)[X] >= (_lo)[X] && (_pt)[X] <= (_hi)[X] && \
2023 (_pt)[Y] >= (_lo)[Y] && (_pt)[Y] <= (_hi)[Y] && \
2024 (_pt)[Z] >= (_lo)[Z] && (_pt)[Z] <= (_hi)[Z])
2031#define V3PNT_IN_RPP_TOL(_pt, _lo, _hi, _t) (\
2032 (_pt)[X] >= (_lo)[X]-(_t) && (_pt)[X] <= (_hi)[X]+(_t) && \
2033 (_pt)[Y] >= (_lo)[Y]-(_t) && (_pt)[Y] <= (_hi)[Y]+(_t) && \
2034 (_pt)[Z] >= (_lo)[Z]-(_t) && (_pt)[Z] <= (_hi)[Z]+(_t))
2040#define V3PNT_OUT_RPP_TOL(_pt, _lo, _hi, _t) (\
2041 (_pt)[X] < (_lo)[X]-(_t) || (_pt)[X] > (_hi)[X]+(_t) || \
2042 (_pt)[Y] < (_lo)[Y]-(_t) || (_pt)[Y] > (_hi)[Y]+(_t) || \
2043 (_pt)[Z] < (_lo)[Z]-(_t) || (_pt)[Z] > (_hi)[Z]+(_t))
2051#define V3RPP1_IN_RPP2(_lo1, _hi1, _lo2, _hi2) (\
2052 (_lo1)[X] >= (_lo2)[X] && (_hi1)[X] <= (_hi2)[X] && \
2053 (_lo1)[Y] >= (_lo2)[Y] && (_hi1)[Y] <= (_hi2)[Y] && \
2054 (_lo1)[Z] >= (_lo2)[Z] && (_hi1)[Z] <= (_hi2)[Z])
2057#define V3DIR_FROM_AZEL(_d, _a, _e) do { \
2058 fastf_t _c_e = cos(_e); \
2059 (_d)[X] = cos(_a) * _c_e; \
2060 (_d)[Y] = sin(_a) * _c_e; \
2061 (_d)[Z] = sin(_e); \
2065#define AZEL_FROM_V3DIR(_a, _e, _d) do { \
2066 (_a) = ((NEAR_ZERO((_d)[X], SMALL_FASTF)) && (NEAR_ZERO((_d)[Y], SMALL_FASTF))) ? 0.0 : atan2(-((_d)[Y]), -((_d)[X])) * -RAD2DEG; \
2067 (_e) = atan2(-((_d)[Z]), sqrt((_d)[X]*(_d)[X] + (_d)[Y]*(_d)[Y])) * -RAD2DEG; \
2072#define VSWAP(_a, _b) do { \
2075 (_a)[X] = (_b)[X]; \
2078 (_a)[Y] = (_b)[Y]; \
2081 (_a)[Z] = (_b)[Z]; \
2086#define V2SWAP(_a, _b) do { \
2089 (_a)[X] = (_b)[X]; \
2092 (_a)[Y] = (_b)[Y]; \
2097#define HSWAP(_a, _b) do { \
2100 (_a)[X] = (_b)[X]; \
2103 (_a)[Y] = (_b)[Y]; \
2106 (_a)[Z] = (_b)[Z]; \
2109 (_a)[W] = (_b)[W]; \
2114#define MAT_SWAP(_a, _b) do { \
2116 MAT_COPY(_t, (_a)); \
2117 MAT_COPY((_a), (_b)); \
2118 MAT_COPY((_b), _t); \
2129#define VINITALL(_v) {(_v), (_v), (_v)}
2137#define V2INITALL(_v) {(_v), (_v), (_v)}
2145#define HINITALL(_v) {(_v), (_v), (_v), (_v)}
2153#define VINIT_ZERO {0.0, 0.0, 0.0}
2161#define V2INIT_ZERO {0.0, 0.0}
2169#define HINIT_ZERO {0.0, 0.0, 0.0, 0.0}
2176#define MAT_INIT_IDN {1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0}
2183#define MAT_INIT_ZERO {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}
Header file for the BRL-CAD common definitions.
fastf_t * pointp_t
pointer to a 3-tuple point
fastf_t vect_t[ELEMENTS_PER_VECT]
3-tuple vector
fastf_t * point2dp_t
pointer to a 2-tuple point
double fastf_t
fastest 64-bit (or larger) floating point type
#define ELEMENTS_PER_POINT
number of fastf_t's per point_t
fastf_t mat_t[ELEMENTS_PER_MAT]
4x4 matrix
fastf_t hvect_t[ELEMENTS_PER_HVECT]
4-tuple vector
enum vmath_matrix_component_ vmath_matrix_component
#define ELEMENTS_PER_PLANE
number of fastf_t's per plane_t
fastf_t point2d_t[ELEMENTS_PER_POINT2D]
2-tuple point
#define ELEMENTS_PER_HVECT
number of fastf_t's per hvect_t (homogeneous vector)
fastf_t * vect2dp_t
pointer to a 2-tuple vector
#define ELEMENTS_PER_POINT2D
number of fastf_t's per point2d_t
#define ELEMENTS_PER_VECT2D
number of fastf_t's per vect2d_t
fastf_t hpoint_t[ELEMENTS_PER_HPOINT]
4-tuple point
fastf_t plane_t[ELEMENTS_PER_PLANE]
Definition of a plane equation.
fastf_t * matp_t
pointer to a 4x4 matrix
#define ELEMENTS_PER_HPOINT
number of fastf_t's per hpt_t (homogeneous point)
fastf_t point_t[ELEMENTS_PER_POINT]
3-tuple point
#define ELEMENTS_PER_VECT
number of fastf_t's per vect_t
hvect_t quat_t
4-element quaternion
fastf_t * vectp_t
pointer to a 3-tuple vector
#define ELEMENTS_PER_MAT
number of fastf_t's per mat_t
fastf_t vect2d_t[ELEMENTS_PER_VECT2D]
2-tuple vector
enum vmath_vector_component_ vmath_vector_component