00001
00002 #ifndef GEOM_H
00003 #define GEOM_H
00004
00005
00006
00007 #define USE_NEW_UNITS FALSE
00008
00009
00010 #define SLERP_SMALL_ANGLE Real(0.01)
00011
00013
00015
00016 #define REAL_SCREEN_XSIZE 640
00017 #define REAL_SCREEN_YSIZE 480
00018 #define REAL_SCREEN_XHALF 320
00019 #define REAL_SCREEN_YHALF 240
00020
00021 #define DivScalar(numerator, divisor) ((numerator) / (divisor))
00022 #define MulScalar(left, right) ((left) * (right))
00023
00024 #define GET_ZBUFFER(z) \
00025 (RenderSettings.FarDivDist - (RenderSettings.FarMulNear / (RenderSettings.DrawDist * (z))))
00026
00027 #define SetVector(_v, _x, _y, _z) \
00028 { \
00029 (_v)->v[X] = _x; \
00030 (_v)->v[Y] = _y; \
00031 (_v)->v[Z] = _z; \
00032 }
00033
00034 #define SubVector(a, b, c) \
00035 (c)->v[X] = (a)->v[X] - (b)->v[X]; \
00036 (c)->v[Y] = (a)->v[Y] - (b)->v[Y]; \
00037 (c)->v[Z] = (a)->v[Z] - (b)->v[Z];
00038
00039 #define AddVector(a, b, c) \
00040 (c)->v[X] = (a)->v[X] + (b)->v[X]; \
00041 (c)->v[Y] = (a)->v[Y] + (b)->v[Y]; \
00042 (c)->v[Z] = (a)->v[Z] + (b)->v[Z];
00043
00044 #define FTOL(_f, _i) \
00045 { \
00046 float _temp = (_f) + (float)(1L << 23); \
00047 (_i) = (*(long*)&_temp) & 0xffffff; \
00048 }
00049
00050 #define FTOL2(_f) \
00051 ((*(long*)&((_f) += (float)(1L << 23))) & 0xffffff)
00052
00053 #define FTOL3(_f) \
00054 (*(long*)&((_f) += (float)(1L << 23)))
00055
00057
00059
00060 #define SetVec(pVec, vx, vy, vz) SetVector(pVec, vx, vy, vz)
00061 #define SetVecZero(vec) SetVec(vec, ZERO, ZERO, ZERO)
00062 #define SetVecUp(vec) SetVec(vec, ZERO, -ONE, ZERO)
00063 #define NegateVec(vec) SetVec(vec, -(vec)->v[X], -(vec)->v[Y], -(vec)->v[Z])
00064 #define VecLen(vec) Length(vec)
00065 #define NormalizeVec(vec) NormalizeVector(vec)
00066 #define VecDotVec(vLeft, vRight) DotProduct(vLeft, vRight)
00067 #define VecCrossVec(vLeft, vRight, vOut) CrossProduct(vLeft, vRight, vOut)
00068
00069 #define CopyVec(src, dest) \
00070 { \
00071 (dest)->v[X] = (src)->v[X]; \
00072 (dest)->v[Y] = (src)->v[Y]; \
00073 (dest)->v[Z] = (src)->v[Z]; \
00074 }
00075
00076 #define VecPlusVec(vecLeft, vecRight, vecOut) \
00077 { \
00078 (vecOut)->v[X] = (vecLeft)->v[X] + (vecRight)->v[X]; \
00079 (vecOut)->v[Y] = (vecLeft)->v[Y] + (vecRight)->v[Y]; \
00080 (vecOut)->v[Z] = (vecLeft)->v[Z] + (vecRight)->v[Z]; \
00081 }
00082
00083 #define VecMinusVec(vecLeft, vecRight, vecOut) \
00084 { \
00085 (vecOut)->v[X] = (vecLeft)->v[X] - (vecRight)->v[X]; \
00086 (vecOut)->v[Y] = (vecLeft)->v[Y] - (vecRight)->v[Y]; \
00087 (vecOut)->v[Z] = (vecLeft)->v[Z] - (vecRight)->v[Z]; \
00088 }
00089
00090 #define VecPlusEqVec(vecLeft, vecRight) \
00091 { \
00092 (vecLeft)->v[X] += (vecRight)->v[X]; \
00093 (vecLeft)->v[Y] += (vecRight)->v[Y]; \
00094 (vecLeft)->v[Z] += (vecRight)->v[Z]; \
00095 }
00096
00097 #define VecMinusEqVec(vecLeft, vecRight) \
00098 { \
00099 (vecLeft)->v[X] -= (vecRight)->v[X]; \
00100 (vecLeft)->v[Y] -= (vecRight)->v[Y]; \
00101 (vecLeft)->v[Z] -= (vecRight)->v[Z]; \
00102 }
00103
00104 #define SetPlane(plane, a, b, c, d) \
00105 { \
00106 (plane)->v[A] = a; \
00107 (plane)->v[B] = b; \
00108 (plane)->v[C] = c; \
00109 (plane)->v[D] = d; \
00110 }
00111
00112 #define CopyPlane(src, dest) \
00113 { \
00114 (dest)->v[A] = (src)->v[A]; \
00115 (dest)->v[B] = (src)->v[B]; \
00116 (dest)->v[C] = (src)->v[C]; \
00117 (dest)->v[D] = (src)->v[D]; \
00118 }
00119
00120 #define PlaneNormal(plane) ((VEC *)(plane))
00121
00122 #define FlipPlane(src, dest) \
00123 { \
00124 (dest)->v[A] = -(src)->v[A]; \
00125 (dest)->v[B] = -(src)->v[B]; \
00126 (dest)->v[C] = -(src)->v[C]; \
00127 (dest)->v[D] = -(src)->v[D]; \
00128 }
00129
00130 #define MatPlusEqMat(matLeft, matRight) \
00131 { \
00132 (matLeft)->m[XX] += (matRight)->m[XX]; \
00133 (matLeft)->m[XY] += (matRight)->m[XY]; \
00134 (matLeft)->m[XZ] += (matRight)->m[XZ]; \
00135 \
00136 (matLeft)->m[YX] += (matRight)->m[YX]; \
00137 (matLeft)->m[YY] += (matRight)->m[YY]; \
00138 (matLeft)->m[YZ] += (matRight)->m[YZ]; \
00139 \
00140 (matLeft)->m[ZX] += (matRight)->m[ZX]; \
00141 (matLeft)->m[ZY] += (matRight)->m[ZY]; \
00142 (matLeft)->m[ZZ] += (matRight)->m[ZZ]; \
00143 }
00144
00146
00148
00149 #define Set4x4Matrix(_m, _t, _r) \
00150 { \
00151 (_r)->_11 = (_m)->m[RX]; \
00152 (_r)->_12 = (_m)->m[RY]; \
00153 (_r)->_13 = (_m)->m[RZ]; \
00154 (_r)->_14 = 0; \
00155 \
00156 (_r)->_21 = (_m)->m[UX]; \
00157 (_r)->_22 = (_m)->m[UY]; \
00158 (_r)->_23 = (_m)->m[UZ]; \
00159 (_r)->_24 = 0; \
00160 \
00161 (_r)->_31 = (_m)->m[LX]; \
00162 (_r)->_32 = (_m)->m[LY]; \
00163 (_r)->_33 = (_m)->m[LZ]; \
00164 (_r)->_34 = 0; \
00165 \
00166 (_r)->_41 = (_t)->v[X]; \
00167 (_r)->_42 = (_t)->v[Y]; \
00168 (_r)->_43 = (_t)->v[Z]; \
00169 (_r)->_44 = 1; \
00170 }
00171
00172 #define CrossProduct(a, b, c) \
00173 { \
00174 (c)->v[X] = (a)->v[Y] * (b)->v[Z] - (a)->v[Z] * (b)->v[Y]; \
00175 (c)->v[Y] = (a)->v[Z] * (b)->v[X] - (a)->v[X] * (b)->v[Z]; \
00176 (c)->v[Z] = (a)->v[X] * (b)->v[Y] - (a)->v[Y] * (b)->v[X]; \
00177 }
00178
00179 #define CrossProduct3(a, b, c) \
00180 ((c)->v[X] * ((a)->v[Y] * (b)->v[Z] - (a)->v[Z] * (b)->v[Y]) + \
00181 (c)->v[Y] * ((a)->v[Z] * (b)->v[X] - (a)->v[X] * (b)->v[Z]) + \
00182 (c)->v[Z] * ((a)->v[X] * (b)->v[Y] - (a)->v[Y] * (b)->v[X]))
00183
00184 #define DotProduct(a, b) \
00185 ((a)->v[X] * (b)->v[X] + (a)->v[Y] * (b)->v[Y] + (a)->v[Z] * (b)->v[Z])
00186
00187 #define Cull(x1, y1, x2, y2, x3, y3) \
00188 (((x1) - (x2)) * ((y3) - (y2)) - ((y1) - (y2)) * ((x3) - (x2)))
00189
00190 #define NormalizeVector(_v) \
00191 { \
00192 REAL _mul = 1 / (REAL)sqrt((_v)->v[X] * (_v)->v[X] + (_v)->v[Y] * (_v)->v[Y] + (_v)->v[Z] * (_v)->v[Z]); \
00193 (_v)->v[X] *= _mul; \
00194 (_v)->v[Y] *= _mul; \
00195 (_v)->v[Z] *= _mul; \
00196 }
00197
00198 #define NormalizeMatrix(m) \
00199 { \
00200 NormalizeVector(&(m)->mv[Y]); \
00201 NormalizeVector(&(m)->mv[Z]); \
00202 CrossProduct(&(m)->mv[Y], &(m)->mv[Z], &(m)->mv[X]); \
00203 CrossProduct(&(m)->mv[Z], &(m)->mv[X], &(m)->mv[Y]); \
00204 }
00205
00206 #define Length(a) \
00207 ((REAL)sqrt((a)->v[X] * (a)->v[X] + (a)->v[Y] * (a)->v[Y] + (a)->v[Z] * (a)->v[Z]))
00208
00209 #define VecMulScalar(vec, scalar) \
00210 { \
00211 (vec)->v[X] *= (scalar); \
00212 (vec)->v[Y] *= (scalar); \
00213 (vec)->v[Z] *= (scalar); \
00214 }
00215
00216 #define VecDivScalar(vec, scalar) \
00217 { \
00218 (vec)->v[X] /= (scalar); \
00219 (vec)->v[Y] /= (scalar); \
00220 (vec)->v[Z] /= (scalar); \
00221 }
00222
00223 #define VecEqScalarVec(vLeft, scalar, vRight) \
00224 { \
00225 (vLeft)->v[X] = (scalar) * (vRight)->v[X]; \
00226 (vLeft)->v[Y] = (scalar) * (vRight)->v[Y]; \
00227 (vLeft)->v[Z] = (scalar) * (vRight)->v[Z]; \
00228 }
00229
00230 #define VecPlusScalarVec(vLeft, scalar, vRight, vOut) \
00231 { \
00232 (vOut)->v[X] = (vLeft)->v[X] + (scalar) * (vRight)->v[X]; \
00233 (vOut)->v[Y] = (vLeft)->v[Y] + (scalar) * (vRight)->v[Y]; \
00234 (vOut)->v[Z] = (vLeft)->v[Z] + (scalar) * (vRight)->v[Z]; \
00235 }
00236
00237 #define ScalarVecPlusScalarVec(scalarL, vLeft, scalarR, vRight, vOut) \
00238 { \
00239 (vOut)->v[X] = (scalarL) * (vLeft)->v[X] + (scalarR) * (vRight)->v[X]; \
00240 (vOut)->v[Y] = (scalarL) * (vLeft)->v[Y] + (scalarR) * (vRight)->v[Y]; \
00241 (vOut)->v[Z] = (scalarL) * (vLeft)->v[Z] + (scalarR) * (vRight)->v[Z]; \
00242 }
00243
00244 #define VecPlusEqScalarVec(vLeft, scalar, vRight) \
00245 { \
00246 (vLeft)->v[X] = (vLeft)->v[X] + (scalar) * (vRight)->v[X]; \
00247 (vLeft)->v[Y] = (vLeft)->v[Y] + (scalar) * (vRight)->v[Y]; \
00248 (vLeft)->v[Z] = (vLeft)->v[Z] + (scalar) * (vRight)->v[Z]; \
00249 }
00250
00251 #define VecMinusScalarVec(vLeft, scalar, vRight, vOut) \
00252 { \
00253 (vOut)->v[X] = (vLeft)->v[X] - (scalar) * (vRight)->v[X]; \
00254 (vOut)->v[Y] = (vLeft)->v[Y] - (scalar) * (vRight)->v[Y]; \
00255 (vOut)->v[Z] = (vLeft)->v[Z] - (scalar) * (vRight)->v[Z]; \
00256 }
00257
00258 #define VecMinusEqScalarVec(vLeft, scalar, vRight) \
00259 { \
00260 (vLeft)->v[X] = (vLeft)->v[X] - (scalar) * (vRight)->v[X]; \
00261 (vLeft)->v[Y] = (vLeft)->v[Y] - (scalar) * (vRight)->v[Y]; \
00262 (vLeft)->v[Z] = (vLeft)->v[Z] - (scalar) * (vRight)->v[Z]; \
00263 }
00264
00265 #define VecDotMulVec(vLeft, vRight, vOut) \
00266 { \
00267 REAL dp = VecDotVec(vLeft, vRight); \
00268 (vOut)->v[X] = dp * (vRight)->v[X]; \
00269 (vOut)->v[Y] = dp * (vRight)->v[Y]; \
00270 (vOut)->v[Z] = dp * (vRight)->v[Z]; \
00271 }
00272
00273 #define VecDotPlane(vec, plane) \
00274 ( (vec)->v[X] * (plane)->v[A] + (vec)->v[Y] * (plane)->v[B] + (vec)->v[Z] * (plane)->v[C] + (plane)->v[D] )
00275
00276 #define PlaneDist(plane, vec) VecDotPlane((vec), (plane))
00277
00278 #define VecDotPlaneNorm(vec, plane) \
00279 ( (vec)->v[X] * (plane)->v[A] + (vec)->v[Y] * (plane)->v[B] + (vec)->v[Z] * (plane)->v[C] )
00280
00281 #define VecCrossVecDotVec(vec1, vec2, vec3) \
00282 ((vec3)->v[X] * ((vec1)->v[Y] * (vec2)->v[Z] - (vec1)->v[Z] * (vec2)->v[Y]) + \
00283 (vec3)->v[Y] * ((vec1)->v[Z] * (vec2)->v[X] - (vec1)->v[X] * (vec2)->v[Z]) + \
00284 (vec3)->v[Z] * ((vec1)->v[X] * (vec2)->v[Y] - (vec1)->v[Y] * (vec2)->v[X]))
00285
00286 #define VecCrossVecDotPlaneNorm(vec1, vec2, plane) VecCrossVecDotVec(vec1, vec2, PlaneNormal(plane))
00287
00288
00289
00290
00291 #define LineInterp(r0, r1, t, rt) \
00292 { \
00293 (rt)->v[X] = (r0)->v[X] + (t) * ((r1)->v[X] - (r0)->v[X]); \
00294 (rt)->v[Y] = (r0)->v[Y] + (t) * ((r1)->v[Y] - (r0)->v[Y]); \
00295 (rt)->v[Z] = (r0)->v[Z] + (t) * ((r1)->v[Z] - (r0)->v[Z]); \
00296 }
00297
00298
00300
00301
00302
00303
00304 #define SetQuat(q, vx, vy, vz, s) \
00305 { \
00306 (q)->v[VX] = (vx); \
00307 (q)->v[VY] = (vy); \
00308 (q)->v[VZ] = (vz); \
00309 (q)->v[S] = (s); \
00310 }
00311
00312 #define CopyQuat(src, dest) \
00313 { \
00314 (dest)->v[VX] = (src)->v[VX]; \
00315 (dest)->v[VY] = (src)->v[VY]; \
00316 (dest)->v[VZ] = (src)->v[VZ]; \
00317 (dest)->v[S] = (src)->v[S]; \
00318 }
00319
00320 #define SetQuatUnit(q) \
00321 { \
00322 (q)->v[VX] = ZERO; \
00323 (q)->v[VY] = ZERO; \
00324 (q)->v[VZ] = ZERO; \
00325 (q)->v[S] = ONE; \
00326 }
00327
00328 #define QuatDotQuat(qLeft, qRight) \
00329 ((qLeft)->v[VX] * (qRight)->v[VX] + \
00330 (qLeft)->v[VY] * (qRight)->v[VY] + \
00331 (qLeft)->v[VZ] * (qRight)->v[VZ] + \
00332 (qLeft)->v[S] * (qRight)->v[S])
00333
00334 #define QuatLen(q) ((REAL)sqrt(QuatDotQuat(q, q)))
00335
00336 #define NormalizeQuat(q) \
00337 { \
00338 REAL qLen = QuatLen(q); \
00339 if (qLen > SMALL_REAL) { \
00340 qLen = ONE / qLen; \
00341 (q)->v[VX] *= qLen; \
00342 (q)->v[VY] *= qLen; \
00343 (q)->v[VZ] *= qLen; \
00344 (q)->v[S] *= qLen; \
00345 } \
00346 }
00347
00348
00349
00350 #define QuatMulQuat(qLeft, qRight, qOut) \
00351 { \
00352 (qOut)->v[VX] = (qLeft)->v[S] * (qRight)->v[VX] + (qLeft)->v[VX] * (qRight)->v[S] + (qLeft)->v[VY] * (qRight)->v[VZ] - (qLeft)->v[VZ] * (qRight)->v[VY]; \
00353 (qOut)->v[VY] = (qLeft)->v[S] * (qRight)->v[VY] + (qLeft)->v[VY] * (qRight)->v[S] + (qLeft)->v[VZ] * (qRight)->v[VX] - (qLeft)->v[VX] * (qRight)->v[VZ]; \
00354 (qOut)->v[VZ] = (qLeft)->v[S] * (qRight)->v[VZ] + (qLeft)->v[VZ] * (qRight)->v[S] + (qLeft)->v[VX] * (qRight)->v[VY] - (qLeft)->v[VY] * (qRight)->v[VX]; \
00355 (qOut)->v[S] = (qLeft)->v[S] * (qRight)->v[S] - (qLeft)->v[VX] * (qRight)->v[VX] - (qLeft)->v[VY] * (qRight)->v[VY] - (qLeft)->v[VZ] * (qRight)->v[VZ]; \
00356 }
00357
00358 #define QuatMulInvQuat(qLeft, qRight, qOut) \
00359 { \
00360 (qOut)->v[VX] = (qLeft)->v[VX] * (qRight)->v[S] - (qLeft)->v[S] * (qRight)->v[VX] - (qLeft)->v[VY] * (qRight)->v[VZ] - (qLeft)->v[VZ] * (qRight)->v[VY]; \
00361 (qOut)->v[VY] = (qLeft)->v[VY] * (qRight)->v[S] - (qLeft)->v[S] * (qRight)->v[VY] - (qLeft)->v[VZ] * (qRight)->v[VX] - (qLeft)->v[VX] * (qRight)->v[VZ]; \
00362 (qOut)->v[VZ] = (qLeft)->v[VZ] * (qRight)->v[S] - (qLeft)->v[S] * (qRight)->v[VZ] - (qLeft)->v[VX] * (qRight)->v[VY] - (qLeft)->v[VY] * (qRight)->v[VX]; \
00363 (qOut)->v[S] = (qLeft)->v[S] * (qRight)->v[S] + (qLeft)->v[VX] * (qRight)->v[VX] + (qLeft)->v[VY] * (qRight)->v[VY] + (qLeft)->v[VZ] * (qRight)->v[VZ]; \
00364 }
00365
00366 #define VecMulQuat(vLeft, qRight, qOut) \
00367 { \
00368 (qOut)->v[VX] = (vLeft)->v[VX] * (qRight)->v[S] + (vLeft)->v[VY] * (qRight)->v[VZ] - (vLeft)->v[VZ] * (qRight)->v[VY]; \
00369 (qOut)->v[VY] = (vLeft)->v[VY] * (qRight)->v[S] + (vLeft)->v[VZ] * (qRight)->v[VX] - (vLeft)->v[VX] * (qRight)->v[VZ]; \
00370 (qOut)->v[VZ] = (vLeft)->v[VZ] * (qRight)->v[S] + (vLeft)->v[VX] * (qRight)->v[VY] - (vLeft)->v[VY] * (qRight)->v[VX]; \
00371 (qOut)->v[S] = - (vLeft)->v[VX] * (qRight)->v[VX] - (vLeft)->v[VY] * (qRight)->v[VY] - (vLeft)->v[VZ] * (qRight)->v[VZ]; \
00372 }
00373
00374 #define ConjQuat(qIn, qOut) \
00375 { \
00376 (qOut)->v[VX] = -(qIn)->v[VX]; \
00377 (qOut)->v[VY] = -(qIn)->v[VY]; \
00378 (qOut)->v[VZ] = -(qIn)->v[VZ]; \
00379 (qOut)->v[S] = (qIn)->v[S]; \
00380 }
00381
00382 #define InvQuat(qIn, qOut) (ConjQuat((qIn), (qOut)))
00383
00384 #define QuatPlusQuat(q1, q2, qOut) \
00385 { \
00386 (qOut)->v[VX] = (q1)->v[VX] + (q2)->v[VX]; \
00387 (qOut)->v[VY] = (q1)->v[VY] + (q2)->v[VY]; \
00388 (qOut)->v[VZ] = (q1)->v[VZ] + (q2)->v[VZ]; \
00389 (qOut)->v[S] = (q1)->v[S] + (q2)->v[S]; \
00390 }
00391
00392 #define QuatMinusQuat(q1, q2, qOut) \
00393 { \
00394 (qOut)->v[VX] = (q1)->v[VX] - (q2)->v[VX]; \
00395 (qOut)->v[VY] = (q1)->v[VY] - (q2)->v[VY]; \
00396 (qOut)->v[VZ] = (q1)->v[VZ] - (q2)->v[VZ]; \
00397 (qOut)->v[S] = (q1)->v[S] - (q2)->v[S]; \
00398 }
00399
00400 #define QuatPlusScalarQuat(q1, s, q2, qOut) \
00401 { \
00402 (qOut)->v[VX] = (q1)->v[VX] + s * (q2)->v[VX]; \
00403 (qOut)->v[VY] = (q1)->v[VY] + s * (q2)->v[VY]; \
00404 (qOut)->v[VZ] = (q1)->v[VZ] + s * (q2)->v[VZ]; \
00405 (qOut)->v[S] = (q1)->v[S] + s * (q2)->v[S]; \
00406 }
00407
00408 #define QuatPlusEqScalarQuat(q1, s, q2) \
00409 { \
00410 (q1)->v[VX] += s * (q2)->v[VX]; \
00411 (q1)->v[VY] += s * (q2)->v[VY]; \
00412 (q1)->v[VZ] += s * (q2)->v[VZ]; \
00413 (q1)->v[S] += s * (q2)->v[S]; \
00414 }
00415
00416 #define VecOfQuat(q) ((VEC *)(q))
00417
00418
00419
00420 #ifndef _CARCONV
00421 extern void RotMatrixX(MAT *mat, REAL rot);
00422 extern void RotMatrixY(MAT *mat, REAL rot);
00423 extern void RotMatrixZ(MAT *mat, REAL rot);
00424 extern void RotMatrixZYX(MAT *mat, REAL x, REAL y, REAL z);
00425 extern void RotVector(MAT *mat, VEC *in, VEC *out);
00426 extern void TransposeRotVector(MAT *mat, VEC *in, VEC *out);
00427 extern void RotTransVector(MAT *mat, VEC *trans, VEC *in, VEC *out);
00428 extern void RotTransPersVector(MAT *mat, VEC *trans, VEC *in, REAL *out);
00429 extern void RotTransPersVectorZleave(MAT *mat, VEC *trans, VEC *in, REAL *out);
00430 extern void RotTransPersVectorZbias(MAT *mat, VEC *trans, VEC *in, REAL *out, REAL zbias);
00431 extern void MulMatrix(MAT *one, MAT *two, MAT *out);
00432 extern void TransposeMatrix(MAT *in, MAT *out);
00433 extern void BuildLookMatrixForward(VEC *pos, VEC *look, MAT *mat);
00434 extern void BuildLookMatrixDown(VEC *pos, VEC *look, MAT *mat);
00435 extern void CopyMatrix(MAT *src, MAT *dest);
00436 extern void BuildMatrixFromLook(MAT *matrix);
00437 extern void BuildMatrixFromUp(MAT *matrix);
00438
00439
00440 extern void SetMat(MAT *mat, REAL xx, REAL xy, REAL xz, REAL yx, REAL yy, REAL yz, REAL zx, REAL zy, REAL zz);
00441 extern void SwapVecs(VEC *a, VEC *b);
00442 extern void CopyMat(MAT *src, MAT *dest);
00443 extern void SetMatZero(MAT *mat);
00444 extern void SetMatUnit(MAT *mat);
00445 extern void MatMulScalar(MAT *mat, REAL scalar);
00446 extern void MatMulVec(MAT *mIn, VEC *vIn, VEC *vOut);
00447 extern void VecMulMat(VEC *vIn, MAT *mIn, VEC *vOut);
00448 extern void MatMulTransMat(MAT *mLeft, MAT *mRight, MAT *mOut);
00449 extern void TransMatMulMat(MAT *mLeft, MAT *mRight, MAT *mOut);
00450 extern void MatMulMat(MAT *mLeft, MAT *mRight, MAT *mOut);
00451 extern void MatPlusMat(MAT *matLeft, MAT *matRight, MAT *matOut);
00452 extern void MatPlusEqScalarMat(MAT *matLeft, REAL scalar, MAT *matRight);
00453 extern void MatMulThisVec(MAT *mIn, VEC *vInOut);
00454 extern void BuildRotation3D(REAL axisX, REAL axisY, REAL axisZ, REAL angle, MAT *mOut);
00455 extern void RotationX(MAT *mat, REAL rot);
00456 extern void RotationY(MAT *mat, REAL rot);
00457 extern void RotationZ(MAT *mat, REAL rot);
00458 extern void BuildMatFromVec(VEC *vec, MAT *mat);
00459 extern void TransMat(MAT *src, MAT *dest) ;
00460 extern void InvertMat(MAT *mat);
00461 extern void BuildCrossMat(VEC *vec, MAT *mat);
00462 extern void MatCrossVec(MAT *matLeft, VEC *vecRight, MAT *matOut);
00463 extern void VecCrossMat(VEC *vecLeft, MAT *matRight, MAT *matOut);
00464 extern void Interpolate3D(VEC *r0, VEC *r1, VEC *r2, REAL t, VEC *rt);
00465 extern void QuadInterpVec(VEC *r0, REAL t0, VEC *r1, REAL t1, VEC *r2, REAL t2, REAL t, VEC *rt);
00466 extern void LInterpVec(VEC *r0, REAL t0, VEC *r1, REAL t1, REAL t, VEC *rt);
00467 extern void BuildPlane(VEC *v1, VEC *v2, VEC *v3, PLANE *plane);
00468 extern void BuildPlane2(VEC *normal, VEC *pt, PLANE *plane);
00469 extern void MovePlane(PLANE *plane, VEC *dR);
00470 extern bool PlaneIntersect3(PLANE *p1, PLANE *p2, PLANE *p3, VEC *r);
00471 extern void RotTransPlane(PLANE *plane, MAT *rotMat, VEC *dR, PLANE *pOut);
00472 extern bool LinePoint(VEC *p, REAL d, VEC *r0, VEC *r1, REAL *t1, REAL *t2);
00473 extern void TestLinePoint(void);
00474 extern REAL NearPointOnLine(VEC *r0, VEC *r1, VEC *p, VEC *rN);
00475 extern void FindIntersection(VEC *point1, REAL dist1, VEC *point2, REAL dist2, VEC *out);
00476
00477 extern void QuatToMat(QUATERNION *quat, MAT *mat);
00478 extern void MatToQuat(MAT *mat, QUATERNION *quat);
00479 extern void InterpQuat(QUATERNION *q1, QUATERNION *q2);
00480 extern void LerpQuat(QUATERNION *q1, QUATERNION *q2, REAL t, QUATERNION *qt);
00481 #ifndef _N64
00482 extern void SLerpQuat(QUATERNION *q1, QUATERNION *q2, REAL t, QUATERNION *qt);
00483 #else
00484 #define SLerpQuat LerpQuat
00485 #endif
00486 extern void QuatRotVec(QUATERNION *quat, VEC *vIn, VEC *vOut);
00487 #endif
00488
00489
00490
00491
00492
00493 extern REAL BaseGeomPers;
00494 extern REAL ScreenLeftClip, ScreenRightClip, ScreenTopClip, ScreenBottomClip;
00495 extern REAL ScreenLeftClipGuard, ScreenRightClipGuard, ScreenTopClipGuard, ScreenBottomClipGuard;
00496 extern MAT IdentityMatrix;
00497 extern MAT Identity;
00498 extern VEC ZeroVector;
00499 extern VEC DownVec;
00500 extern VEC UpVec;
00501 extern VEC RightVec;
00502 extern VEC LeftVec;
00503 extern VEC LookVec;
00504 extern VEC NegLookVec;
00505 extern QUATERNION IdentityQuat;
00506
00507 #endif