2 Copyright (C) 1996-1997 Id Software, Inc.
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 See the GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 // mathlib.c -- math primitives
25 void Sys_Error (char *error, ...);
27 vec3_t vec3_origin = {0,0,0};
30 /*-----------------------------------------------------------------*/
32 float m_bytenormals[NUMVERTEXNORMALS][3] =
34 {-0.525731, 0.000000, 0.850651}, {-0.442863, 0.238856, 0.864188},
35 {-0.295242, 0.000000, 0.955423}, {-0.309017, 0.500000, 0.809017},
36 {-0.162460, 0.262866, 0.951056}, {0.000000, 0.000000, 1.000000},
37 {0.000000, 0.850651, 0.525731}, {-0.147621, 0.716567, 0.681718},
38 {0.147621, 0.716567, 0.681718}, {0.000000, 0.525731, 0.850651},
39 {0.309017, 0.500000, 0.809017}, {0.525731, 0.000000, 0.850651},
40 {0.295242, 0.000000, 0.955423}, {0.442863, 0.238856, 0.864188},
41 {0.162460, 0.262866, 0.951056}, {-0.681718, 0.147621, 0.716567},
42 {-0.809017, 0.309017, 0.500000}, {-0.587785, 0.425325, 0.688191},
43 {-0.850651, 0.525731, 0.000000}, {-0.864188, 0.442863, 0.238856},
44 {-0.716567, 0.681718, 0.147621}, {-0.688191, 0.587785, 0.425325},
45 {-0.500000, 0.809017, 0.309017}, {-0.238856, 0.864188, 0.442863},
46 {-0.425325, 0.688191, 0.587785}, {-0.716567, 0.681718, -0.147621},
47 {-0.500000, 0.809017, -0.309017}, {-0.525731, 0.850651, 0.000000},
48 {0.000000, 0.850651, -0.525731}, {-0.238856, 0.864188, -0.442863},
49 {0.000000, 0.955423, -0.295242}, {-0.262866, 0.951056, -0.162460},
50 {0.000000, 1.000000, 0.000000}, {0.000000, 0.955423, 0.295242},
51 {-0.262866, 0.951056, 0.162460}, {0.238856, 0.864188, 0.442863},
52 {0.262866, 0.951056, 0.162460}, {0.500000, 0.809017, 0.309017},
53 {0.238856, 0.864188, -0.442863}, {0.262866, 0.951056, -0.162460},
54 {0.500000, 0.809017, -0.309017}, {0.850651, 0.525731, 0.000000},
55 {0.716567, 0.681718, 0.147621}, {0.716567, 0.681718, -0.147621},
56 {0.525731, 0.850651, 0.000000}, {0.425325, 0.688191, 0.587785},
57 {0.864188, 0.442863, 0.238856}, {0.688191, 0.587785, 0.425325},
58 {0.809017, 0.309017, 0.500000}, {0.681718, 0.147621, 0.716567},
59 {0.587785, 0.425325, 0.688191}, {0.955423, 0.295242, 0.000000},
60 {1.000000, 0.000000, 0.000000}, {0.951056, 0.162460, 0.262866},
61 {0.850651, -0.525731, 0.000000}, {0.955423, -0.295242, 0.000000},
62 {0.864188, -0.442863, 0.238856}, {0.951056, -0.162460, 0.262866},
63 {0.809017, -0.309017, 0.500000}, {0.681718, -0.147621, 0.716567},
64 {0.850651, 0.000000, 0.525731}, {0.864188, 0.442863, -0.238856},
65 {0.809017, 0.309017, -0.500000}, {0.951056, 0.162460, -0.262866},
66 {0.525731, 0.000000, -0.850651}, {0.681718, 0.147621, -0.716567},
67 {0.681718, -0.147621, -0.716567}, {0.850651, 0.000000, -0.525731},
68 {0.809017, -0.309017, -0.500000}, {0.864188, -0.442863, -0.238856},
69 {0.951056, -0.162460, -0.262866}, {0.147621, 0.716567, -0.681718},
70 {0.309017, 0.500000, -0.809017}, {0.425325, 0.688191, -0.587785},
71 {0.442863, 0.238856, -0.864188}, {0.587785, 0.425325, -0.688191},
72 {0.688191, 0.587785, -0.425325}, {-0.147621, 0.716567, -0.681718},
73 {-0.309017, 0.500000, -0.809017}, {0.000000, 0.525731, -0.850651},
74 {-0.525731, 0.000000, -0.850651}, {-0.442863, 0.238856, -0.864188},
75 {-0.295242, 0.000000, -0.955423}, {-0.162460, 0.262866, -0.951056},
76 {0.000000, 0.000000, -1.000000}, {0.295242, 0.000000, -0.955423},
77 {0.162460, 0.262866, -0.951056}, {-0.442863, -0.238856, -0.864188},
78 {-0.309017, -0.500000, -0.809017}, {-0.162460, -0.262866, -0.951056},
79 {0.000000, -0.850651, -0.525731}, {-0.147621, -0.716567, -0.681718},
80 {0.147621, -0.716567, -0.681718}, {0.000000, -0.525731, -0.850651},
81 {0.309017, -0.500000, -0.809017}, {0.442863, -0.238856, -0.864188},
82 {0.162460, -0.262866, -0.951056}, {0.238856, -0.864188, -0.442863},
83 {0.500000, -0.809017, -0.309017}, {0.425325, -0.688191, -0.587785},
84 {0.716567, -0.681718, -0.147621}, {0.688191, -0.587785, -0.425325},
85 {0.587785, -0.425325, -0.688191}, {0.000000, -0.955423, -0.295242},
86 {0.000000, -1.000000, 0.000000}, {0.262866, -0.951056, -0.162460},
87 {0.000000, -0.850651, 0.525731}, {0.000000, -0.955423, 0.295242},
88 {0.238856, -0.864188, 0.442863}, {0.262866, -0.951056, 0.162460},
89 {0.500000, -0.809017, 0.309017}, {0.716567, -0.681718, 0.147621},
90 {0.525731, -0.850651, 0.000000}, {-0.238856, -0.864188, -0.442863},
91 {-0.500000, -0.809017, -0.309017}, {-0.262866, -0.951056, -0.162460},
92 {-0.850651, -0.525731, 0.000000}, {-0.716567, -0.681718, -0.147621},
93 {-0.716567, -0.681718, 0.147621}, {-0.525731, -0.850651, 0.000000},
94 {-0.500000, -0.809017, 0.309017}, {-0.238856, -0.864188, 0.442863},
95 {-0.262866, -0.951056, 0.162460}, {-0.864188, -0.442863, 0.238856},
96 {-0.809017, -0.309017, 0.500000}, {-0.688191, -0.587785, 0.425325},
97 {-0.681718, -0.147621, 0.716567}, {-0.442863, -0.238856, 0.864188},
98 {-0.587785, -0.425325, 0.688191}, {-0.309017, -0.500000, 0.809017},
99 {-0.147621, -0.716567, 0.681718}, {-0.425325, -0.688191, 0.587785},
100 {-0.162460, -0.262866, 0.951056}, {0.442863, -0.238856, 0.864188},
101 {0.162460, -0.262866, 0.951056}, {0.309017, -0.500000, 0.809017},
102 {0.147621, -0.716567, 0.681718}, {0.000000, -0.525731, 0.850651},
103 {0.425325, -0.688191, 0.587785}, {0.587785, -0.425325, 0.688191},
104 {0.688191, -0.587785, 0.425325}, {-0.955423, 0.295242, 0.000000},
105 {-0.951056, 0.162460, 0.262866}, {-1.000000, 0.000000, 0.000000},
106 {-0.850651, 0.000000, 0.525731}, {-0.955423, -0.295242, 0.000000},
107 {-0.951056, -0.162460, 0.262866}, {-0.864188, 0.442863, -0.238856},
108 {-0.951056, 0.162460, -0.262866}, {-0.809017, 0.309017, -0.500000},
109 {-0.864188, -0.442863, -0.238856}, {-0.951056, -0.162460, -0.262866},
110 {-0.809017, -0.309017, -0.500000}, {-0.681718, 0.147621, -0.716567},
111 {-0.681718, -0.147621, -0.716567}, {-0.850651, 0.000000, -0.525731},
112 {-0.688191, 0.587785, -0.425325}, {-0.587785, 0.425325, -0.688191},
113 {-0.425325, 0.688191, -0.587785}, {-0.425325, -0.688191, -0.587785},
114 {-0.587785, -0.425325, -0.688191}, {-0.688191, -0.587785, -0.425325},
117 qbyte NormalToByte(const vec3_t n)
120 float bestdistance, distance;
123 bestdistance = DotProduct (n, m_bytenormals[0]);
124 for (i = 1;i < NUMVERTEXNORMALS;i++)
126 distance = DotProduct (n, m_bytenormals[i]);
127 if (distance > bestdistance)
129 bestdistance = distance;
136 // note: uses byte partly to force unsigned for the validity check
137 void ByteToNormal(qbyte num, vec3_t n)
139 if (num < NUMVERTEXNORMALS)
140 VectorCopy(m_bytenormals[num], n);
142 VectorClear(n); // FIXME: complain?
145 float Q_RSqrt(float number)
152 *((int *)&y) = 0x5f3759df - ((* (int *) &number) >> 1);
153 return y * (1.5f - (number * 0.5f * y * y));
157 // assumes "src" is normalized
158 void PerpendicularVector( vec3_t dst, const vec3_t src )
160 // LordHavoc: optimized to death and beyond
174 minelem = fabs(src[0]);
175 if (fabs(src[1]) < minelem)
178 minelem = fabs(src[1]);
180 if (fabs(src[2]) < minelem)
184 dst[0] -= src[pos] * src[0];
185 dst[1] -= src[pos] * src[1];
186 dst[2] -= src[pos] * src[2];
188 // normalize the result
189 VectorNormalize(dst);
209 // LordHavoc: like AngleVectors, but taking a forward vector instead of angles, useful!
210 void VectorVectors(const vec3_t forward, vec3_t right, vec3_t up)
214 right[0] = forward[2];
215 right[1] = -forward[0];
216 right[2] = forward[1];
218 d = DotProduct(forward, right);
219 right[0] -= d * forward[0];
220 right[1] -= d * forward[1];
221 right[2] -= d * forward[2];
222 VectorNormalizeFast(right);
223 CrossProduct(right, forward, up);
226 void VectorVectorsDouble(const double *forward, double *right, double *up)
230 right[0] = forward[2];
231 right[1] = -forward[0];
232 right[2] = forward[1];
234 d = DotProduct(forward, right);
235 right[0] -= d * forward[0];
236 right[1] -= d * forward[1];
237 right[2] -= d * forward[2];
238 VectorNormalize(right);
239 CrossProduct(right, forward, up);
242 void RotatePointAroundVector( vec3_t dst, const vec3_t dir, const vec3_t point, float degrees )
248 angle = DEG2RAD(degrees);
257 VectorVectors(vf, vr, vu);
259 t0 = vr[0] * c + vu[0] * -s;
260 t1 = vr[0] * s + vu[0] * c;
261 dst[0] = (t0 * vr[0] + t1 * vu[0] + vf[0] * vf[0]) * point[0]
262 + (t0 * vr[1] + t1 * vu[1] + vf[0] * vf[1]) * point[1]
263 + (t0 * vr[2] + t1 * vu[2] + vf[0] * vf[2]) * point[2];
265 t0 = vr[1] * c + vu[1] * -s;
266 t1 = vr[1] * s + vu[1] * c;
267 dst[1] = (t0 * vr[0] + t1 * vu[0] + vf[1] * vf[0]) * point[0]
268 + (t0 * vr[1] + t1 * vu[1] + vf[1] * vf[1]) * point[1]
269 + (t0 * vr[2] + t1 * vu[2] + vf[1] * vf[2]) * point[2];
271 t0 = vr[2] * c + vu[2] * -s;
272 t1 = vr[2] * s + vu[2] * c;
273 dst[2] = (t0 * vr[0] + t1 * vu[0] + vf[2] * vf[0]) * point[0]
274 + (t0 * vr[1] + t1 * vu[1] + vf[2] * vf[1]) * point[1]
275 + (t0 * vr[2] + t1 * vu[2] + vf[2] * vf[2]) * point[2];
278 /*-----------------------------------------------------------------*/
282 // BoxOnPlaneSide did a switch on a 'signbits' value and had optimized
283 // assembly in an attempt to accelerate it further, very inefficient
284 // considering that signbits of the frustum planes only changed each
285 // frame, and the world planes changed only at load time.
286 // So, to optimize it further I took the obvious route of storing a function
287 // pointer in the plane struct itself, and shrunk each of the individual
288 // cases to a single return statement.
290 // realized axial cases would be a nice speedup for world geometry, although
291 // never useful for the frustum planes.
292 int BoxOnPlaneSideX (vec3_t emins, vec3_t emaxs, mplane_t *p) {return p->dist <= emins[0] ? 1 : (p->dist >= emaxs[0] ? 2 : 3);}
293 int BoxOnPlaneSideY (vec3_t emins, vec3_t emaxs, mplane_t *p) {return p->dist <= emins[1] ? 1 : (p->dist >= emaxs[1] ? 2 : 3);}
294 int BoxOnPlaneSideZ (vec3_t emins, vec3_t emaxs, mplane_t *p) {return p->dist <= emins[2] ? 1 : (p->dist >= emaxs[2] ? 2 : 3);}
295 int BoxOnPlaneSide0 (vec3_t emins, vec3_t emaxs, mplane_t *p) {return (((p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2]) >= p->dist) | (((p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2]) < p->dist) << 1));}
296 int BoxOnPlaneSide1 (vec3_t emins, vec3_t emaxs, mplane_t *p) {return (((p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2]) >= p->dist) | (((p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2]) < p->dist) << 1));}
297 int BoxOnPlaneSide2 (vec3_t emins, vec3_t emaxs, mplane_t *p) {return (((p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2]) >= p->dist) | (((p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2]) < p->dist) << 1));}
298 int BoxOnPlaneSide3 (vec3_t emins, vec3_t emaxs, mplane_t *p) {return (((p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2]) >= p->dist) | (((p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2]) < p->dist) << 1));}
299 int BoxOnPlaneSide4 (vec3_t emins, vec3_t emaxs, mplane_t *p) {return (((p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2]) >= p->dist) | (((p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2]) < p->dist) << 1));}
300 int BoxOnPlaneSide5 (vec3_t emins, vec3_t emaxs, mplane_t *p) {return (((p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2]) >= p->dist) | (((p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2]) < p->dist) << 1));}
301 int BoxOnPlaneSide6 (vec3_t emins, vec3_t emaxs, mplane_t *p) {return (((p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2]) >= p->dist) | (((p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2]) < p->dist) << 1));}
302 int BoxOnPlaneSide7 (vec3_t emins, vec3_t emaxs, mplane_t *p) {return (((p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2]) >= p->dist) | (((p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2]) < p->dist) << 1));}
304 void BoxOnPlaneSideClassify(mplane_t *p)
309 p->BoxOnPlaneSideFunc = BoxOnPlaneSideX;
312 p->BoxOnPlaneSideFunc = BoxOnPlaneSideY;
315 p->BoxOnPlaneSideFunc = BoxOnPlaneSideZ;
318 if (p->normal[2] < 0) // 4
320 if (p->normal[1] < 0) // 2
322 if (p->normal[0] < 0) // 1
323 p->BoxOnPlaneSideFunc = BoxOnPlaneSide7;
325 p->BoxOnPlaneSideFunc = BoxOnPlaneSide6;
329 if (p->normal[0] < 0) // 1
330 p->BoxOnPlaneSideFunc = BoxOnPlaneSide5;
332 p->BoxOnPlaneSideFunc = BoxOnPlaneSide4;
337 if (p->normal[1] < 0) // 2
339 if (p->normal[0] < 0) // 1
340 p->BoxOnPlaneSideFunc = BoxOnPlaneSide3;
342 p->BoxOnPlaneSideFunc = BoxOnPlaneSide2;
346 if (p->normal[0] < 0) // 1
347 p->BoxOnPlaneSideFunc = BoxOnPlaneSide1;
349 p->BoxOnPlaneSideFunc = BoxOnPlaneSide0;
356 void PlaneClassify(mplane_t *p)
358 if (p->normal[0] == 1)
360 else if (p->normal[1] == 1)
362 else if (p->normal[2] == 1)
366 BoxOnPlaneSideClassify(p);
369 void AngleVectors (const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up)
371 double angle, sr, sp, sy, cr, cp, cy;
373 angle = angles[YAW] * (M_PI*2 / 360);
376 angle = angles[PITCH] * (M_PI*2 / 360);
387 angle = angles[ROLL] * (M_PI*2 / 360);
392 right[0] = -1*(sr*sp*cy+cr*-sy);
393 right[1] = -1*(sr*sp*sy+cr*cy);
394 right[2] = -1*(sr*cp);
398 up[0] = (cr*sp*cy+-sr*-sy);
399 up[1] = (cr*sp*sy+-sr*cy);
405 void AngleVectorsFLU (const vec3_t angles, vec3_t forward, vec3_t left, vec3_t up)
407 double angle, sr, sp, sy, cr, cp, cy;
409 angle = angles[YAW] * (M_PI*2 / 360);
412 angle = angles[PITCH] * (M_PI*2 / 360);
423 angle = angles[ROLL] * (M_PI*2 / 360);
428 left[0] = sr*sp*cy+cr*-sy;
429 left[1] = sr*sp*sy+cr*cy;
434 up[0] = cr*sp*cy+-sr*-sy;
435 up[1] = cr*sp*sy+-sr*cy;
441 void AngleMatrix (const vec3_t angles, const vec3_t translate, vec_t matrix[][4])
443 double angle, sr, sp, sy, cr, cp, cy;
445 angle = angles[YAW] * (M_PI*2 / 360);
448 angle = angles[PITCH] * (M_PI*2 / 360);
451 angle = angles[ROLL] * (M_PI*2 / 360);
454 matrix[0][0] = cp*cy;
455 matrix[0][1] = sr*sp*cy+cr*-sy;
456 matrix[0][2] = cr*sp*cy+-sr*-sy;
457 matrix[0][3] = translate[0];
458 matrix[1][0] = cp*sy;
459 matrix[1][1] = sr*sp*sy+cr*cy;
460 matrix[1][2] = cr*sp*sy+-sr*cy;
461 matrix[1][3] = translate[1];
463 matrix[2][1] = sr*cp;
464 matrix[2][2] = cr*cp;
465 matrix[2][3] = translate[2];
469 // LordHavoc: renamed these to Length, and made the normal ones #define
470 float VectorNormalizeLength (vec3_t v)
472 float length, ilength;
474 length = v[0]*v[0] + v[1]*v[1] + v[2]*v[2];
475 length = sqrt (length); // FIXME
495 void R_ConcatRotations (const float in1[3*3], const float in2[3*3], float out[3*3])
497 out[0*3+ 0] = in1[0*3+ 0] * in2[0*3+ 0] + in1[0*3+ 1] * in2[1*3+ 0] + in1[0*3+ 2] * in2[2*3+ 0];
498 out[0*3+ 1] = in1[0*3+ 0] * in2[0*3+ 1] + in1[0*3+ 1] * in2[1*3+ 1] + in1[0*3+ 2] * in2[2*3+ 1];
499 out[0*3+ 2] = in1[0*3+ 0] * in2[0*3+ 2] + in1[0*3+ 1] * in2[1*3+ 2] + in1[0*3+ 2] * in2[2*3+ 2];
500 out[1*3+ 0] = in1[1*3+ 0] * in2[0*3+ 0] + in1[1*3+ 1] * in2[1*3+ 0] + in1[1*3+ 2] * in2[2*3+ 0];
501 out[1*3+ 1] = in1[1*3+ 0] * in2[0*3+ 1] + in1[1*3+ 1] * in2[1*3+ 1] + in1[1*3+ 2] * in2[2*3+ 1];
502 out[1*3+ 2] = in1[1*3+ 0] * in2[0*3+ 2] + in1[1*3+ 1] * in2[1*3+ 2] + in1[1*3+ 2] * in2[2*3+ 2];
503 out[2*3+ 0] = in1[2*3+ 0] * in2[0*3+ 0] + in1[2*3+ 1] * in2[1*3+ 0] + in1[2*3+ 2] * in2[2*3+ 0];
504 out[2*3+ 1] = in1[2*3+ 0] * in2[0*3+ 1] + in1[2*3+ 1] * in2[1*3+ 1] + in1[2*3+ 2] * in2[2*3+ 1];
505 out[2*3+ 2] = in1[2*3+ 0] * in2[0*3+ 2] + in1[2*3+ 1] * in2[1*3+ 2] + in1[2*3+ 2] * in2[2*3+ 2];
514 void R_ConcatTransforms (const float in1[3*4], const float in2[3*4], float out[3*4])
516 out[0*4+0] = in1[0*4+0] * in2[0*4+0] + in1[0*4+1] * in2[1*4+0] + in1[0*4+2] * in2[2*4+0];
517 out[0*4+1] = in1[0*4+0] * in2[0*4+1] + in1[0*4+1] * in2[1*4+1] + in1[0*4+2] * in2[2*4+1];
518 out[0*4+2] = in1[0*4+0] * in2[0*4+2] + in1[0*4+1] * in2[1*4+2] + in1[0*4+2] * in2[2*4+2];
519 out[0*4+3] = in1[0*4+0] * in2[0*4+3] + in1[0*4+1] * in2[1*4+3] + in1[0*4+2] * in2[2*4+3] + in1[0*4+3];
520 out[1*4+0] = in1[1*4+0] * in2[0*4+0] + in1[1*4+1] * in2[1*4+0] + in1[1*4+2] * in2[2*4+0];
521 out[1*4+1] = in1[1*4+0] * in2[0*4+1] + in1[1*4+1] * in2[1*4+1] + in1[1*4+2] * in2[2*4+1];
522 out[1*4+2] = in1[1*4+0] * in2[0*4+2] + in1[1*4+1] * in2[1*4+2] + in1[1*4+2] * in2[2*4+2];
523 out[1*4+3] = in1[1*4+0] * in2[0*4+3] + in1[1*4+1] * in2[1*4+3] + in1[1*4+2] * in2[2*4+3] + in1[1*4+3];
524 out[2*4+0] = in1[2*4+0] * in2[0*4+0] + in1[2*4+1] * in2[1*4+0] + in1[2*4+2] * in2[2*4+0];
525 out[2*4+1] = in1[2*4+0] * in2[0*4+1] + in1[2*4+1] * in2[1*4+1] + in1[2*4+2] * in2[2*4+1];
526 out[2*4+2] = in1[2*4+0] * in2[0*4+2] + in1[2*4+1] * in2[1*4+2] + in1[2*4+2] * in2[2*4+2];
527 out[2*4+3] = in1[2*4+0] * in2[0*4+3] + in1[2*4+1] * in2[1*4+3] + in1[2*4+2] * in2[2*4+3] + in1[2*4+3];
531 void Mathlib_Init(void)
535 // LordHavoc: setup 1.0f / N table for quick recipricols of integers
537 for (a = 1;a < 4096;a++)
538 ixtable[a] = 1.0f / a;