00001
00002
00003
00004
00005
00006
00007
00008 #ifndef __SP_DIMENSION_MATRIX3_H__
00009 #define __SP_DIMENSION_MATRIX3_H__
00010
00011
00012 #include "Base/spStandard.hpp"
00013 #include "Base/spMath.hpp"
00014
00015 #include <string.h>
00016
00017
00018 namespace sp
00019 {
00020 namespace dim
00021 {
00022
00023
00024 template <typename T> class matrix3
00025 {
00026
00027 public:
00028
00029 matrix3()
00030 {
00031 reset();
00032 }
00033 matrix3(const T (&Other)[9])
00034 {
00035 *this = Other;
00036 }
00037 matrix3(const matrix3<T> &Other)
00038 {
00039 *this = Other;
00040 }
00041 matrix3(
00042 T m1n1, T m2n1, T m3n1,
00043 T m1n2, T m2n2, T m3n2,
00044 T m1n3, T m2n3, T m3n3)
00045 {
00046 M[0] = m1n1; M[3] = m2n1; M[6] = m3n1;
00047 M[1] = m1n2; M[4] = m2n2; M[7] = m3n2;
00048 M[2] = m1n3; M[5] = m2n3; M[8] = m3n3;
00049 }
00050 ~matrix3()
00051 {
00052 }
00053
00054
00055
00056 inline const T& operator () (s32 row, s32 col) const
00057 {
00058 return M[ (row * 3) + col ];
00059 }
00060 inline T& operator () (s32 row, s32 col)
00061 {
00062 return M[ (row * 3) + col ];
00063 }
00064
00065 inline const T operator [] (u32 i) const
00066 {
00067 return i < 9 ? M[i] : (T)0;
00068 }
00069 inline T& operator [] (u32 i)
00070 {
00071 return M[i];
00072 }
00073
00074 inline bool operator == (const matrix3<T> &other)
00075 {
00076 for (s32 i = 0; i < 9; ++i)
00077 {
00078 if (M[i] != other.M[i])
00079 return false;
00080 }
00081 return true;
00082 }
00083 inline bool operator != (const matrix3<T> &other)
00084 {
00085 for (s32 i = 0; i < 9; ++i)
00086 {
00087 if (M[i] != other.M[i])
00088 return true;
00089 }
00090 return false;
00091 }
00092
00093 inline matrix3<T>& operator = (const T (&other)[9])
00094 {
00095 M[0] = other[0]; M[3] = other[3]; M[6] = other[6];
00096 M[1] = other[1]; M[4] = other[4]; M[7] = other[7];
00097 M[2] = other[2]; M[5] = other[5]; M[8] = other[8];
00098 return *this;
00099 }
00100 inline matrix3<T>& operator = (const matrix3<T> &other)
00101 {
00102 M[0] = other[0]; M[3] = other[3]; M[6] = other[6];
00103 M[1] = other[1]; M[4] = other[4]; M[7] = other[7];
00104 M[2] = other[2]; M[5] = other[5]; M[8] = other[8];
00105 return *this;
00106 }
00107 inline matrix3<T>& operator = (T Scalar)
00108 {
00109 memset(M, Scalar, sizeof(M));
00110 return *this;
00111 }
00112
00113 inline matrix3<T> operator + (const matrix3<T> &mltMatrix) const
00114 {
00115 matrix3<T> other;
00116
00117 other[0] = M[0] + mltMatrix[0]; other[3] = M[3] + mltMatrix[3]; other[6] = M[6] + mltMatrix[6];
00118 other[1] = M[1] + mltMatrix[1]; other[4] = M[4] + mltMatrix[4]; other[7] = M[7] + mltMatrix[7];
00119 other[2] = M[2] + mltMatrix[2]; other[5] = M[5] + mltMatrix[5]; other[8] = M[8] + mltMatrix[8];
00120
00121 return other;
00122 }
00123
00124 inline matrix3<T>& operator += (const matrix3<T> &mltMatrix)
00125 {
00126 M[0] += mltMatrix[0]; M[3] += mltMatrix[3]; M[6] += mltMatrix[6];
00127 M[1] += mltMatrix[1]; M[4] += mltMatrix[4]; M[7] += mltMatrix[7];
00128 M[2] += mltMatrix[2]; M[5] += mltMatrix[5]; M[8] += mltMatrix[8];
00129 return *this;
00130 }
00131
00132 inline matrix3<T> operator - (const matrix3<T> &mltMatrix) const
00133 {
00134 matrix3<T> other;
00135 other[0] = M[0] - mltMatrix[0]; other[3] = M[3] - mltMatrix[3]; other[6] = M[6] - mltMatrix[6];
00136 other[1] = M[1] - mltMatrix[1]; other[4] = M[4] - mltMatrix[4]; other[7] = M[7] - mltMatrix[7];
00137 other[2] = M[2] - mltMatrix[2]; other[5] = M[5] - mltMatrix[5]; other[8] = M[8] - mltMatrix[8];
00138 return other;
00139 }
00140 inline matrix3<T>& operator -= (const matrix3<T> &mltMatrix)
00141 {
00142 M[0] -= mltMatrix[0]; M[3] -= mltMatrix[3]; M[6] -= mltMatrix[6];
00143 M[1] -= mltMatrix[1]; M[4] -= mltMatrix[4]; M[7] -= mltMatrix[7];
00144 M[2] -= mltMatrix[2]; M[5] -= mltMatrix[5]; M[8] -= mltMatrix[8];
00145 return *this;
00146 }
00147
00148 inline matrix3<T> operator * (const matrix3<T> &mltMatrix) const
00149 {
00150 matrix3<T> m3;
00151 const T* m1 = M;
00152 const T* m2 = mltMatrix.M;
00153
00154 m3[0] = m1[0]*m2[0] + m1[3]*m2[1] + m1[6]*m2[2];
00155 m3[1] = m1[1]*m2[0] + m1[4]*m2[1] + m1[7]*m2[2];
00156 m3[2] = m1[2]*m2[0] + m1[5]*m2[1] + m1[8]*m2[2];
00157
00158 m3[3] = m1[0]*m2[3] + m1[3]*m2[4] + m1[6]*m2[5];
00159 m3[4] = m1[1]*m2[3] + m1[4]*m2[4] + m1[7]*m2[5];
00160 m3[5] = m1[2]*m2[3] + m1[5]*m2[4] + m1[8]*m2[5];
00161
00162 m3[6] = m1[0]*m2[6] + m1[3]*m2[7] + m1[6]*m2[8];
00163 m3[7] = m1[1]*m2[6] + m1[4]*m2[7] + m1[7]*m2[8];
00164 m3[8] = m1[2]*m2[6] + m1[5]*m2[7] + m1[8]*m2[8];
00165
00166 return m3;
00167 }
00168
00169 inline matrix3<T> operator * (const T &Scalar) const
00170 {
00171 matrix3<T> other;
00172
00173 other[0] = M[0]*Scalar; other[3] = M[3]*Scalar; other[6] = M[6]*Scalar;
00174 other[1] = M[1]*Scalar; other[4] = M[4]*Scalar; other[7] = M[7]*Scalar;
00175 other[2] = M[2]*Scalar; other[5] = M[5]*Scalar; other[8] = M[8]*Scalar;
00176
00177 return other;
00178 }
00179
00180 inline matrix3<T>& operator *= (const matrix3<T> &mltMatrix)
00181 {
00182 T m1[16];
00183 memcpy(m1, M, sizeof(M));
00184 const T* m2 = mltMatrix.M;
00185
00186 M[0] = m1[0]*m2[0] + m1[3]*m2[1] + m1[6]*m2[2];
00187 M[1] = m1[1]*m2[0] + m1[4]*m2[1] + m1[7]*m2[2];
00188 M[2] = m1[2]*m2[0] + m1[5]*m2[1] + m1[8]*m2[2];
00189
00190 M[3] = m1[0]*m2[3] + m1[3]*m2[4] + m1[6]*m2[5];
00191 M[4] = m1[1]*m2[3] + m1[4]*m2[4] + m1[7]*m2[5];
00192 M[5] = m1[2]*m2[3] + m1[5]*m2[4] + m1[8]*m2[5];
00193
00194 M[6] = m1[0]*m2[6] + m1[3]*m2[7] + m1[6]*m2[8];
00195 M[7] = m1[1]*m2[6] + m1[4]*m2[7] + m1[7]*m2[8];
00196 M[8] = m1[2]*m2[6] + m1[5]*m2[7] + m1[8]*m2[8];
00197
00198 return *this;
00199 }
00200
00201 inline matrix3<T>& operator *= (T Scalar)
00202 {
00203 M[0] *= Scalar; M[3] *= Scalar; M[6] *= Scalar;
00204 M[1] *= Scalar; M[4] *= Scalar; M[7] *= Scalar;
00205 M[2] *= Scalar; M[5] *= Scalar; M[8] *= Scalar;
00206 return *this;
00207 }
00208
00209
00210
00211
00212
00213
00214 inline vector3d<T> operator * (const vector3d<T> &Vector) const
00215 {
00216 return vector3d<T>(
00217 Vector.X*M[0] + Vector.Y*M[3] + Vector.Z*M[6],
00218 Vector.X*M[1] + Vector.Y*M[4] + Vector.Z*M[7],
00219 Vector.X*M[2] + Vector.Y*M[5] + Vector.Z*M[8]
00220 );
00221 }
00222
00223 inline point2d<T> operator * (const point2d<T> &Vector) const
00224 {
00225 return point2d<T>(
00226 Vector.X*M[0] + Vector.Y*M[3],
00227 Vector.X*M[1] + Vector.Y*M[4]
00228 );
00229 }
00230
00231 inline triangle3d<T> operator * (const triangle3d<T> &Triangle) const
00232 {
00233 return triangle3d<T>(
00234 *this * Triangle.PointA,
00235 *this * Triangle.PointB,
00236 *this * Triangle.PointC
00237 );
00238 }
00239
00240 inline triangle3d<T> operator * (const triangle3d<T, vector3d<T>*> &Triangle) const
00241 {
00242 return triangle3d<T>(
00243 *this * (*Triangle.PointA),
00244 *this * (*Triangle.PointB),
00245 *this * (*Triangle.PointC)
00246 );
00247 }
00248
00249 inline plane3d<T> operator * (const plane3d<T> &Plane) const
00250 {
00251 plane3d<T> NewPlane(Plane);
00252
00253 vector3d<T> Member( *this * ( - NewPlane.Normal * NewPlane.Distance ) );
00254
00255 vector3d<T> Origin;
00256 NewPlane.Normal = *this * NewPlane.Normal;
00257 Origin = *this * Origin;
00258
00259 NewPlane.Normal -= Origin;
00260 NewPlane.Distance = - Member.dot(NewPlane.Normal);
00261
00262 return NewPlane;
00263 }
00264
00265
00266
00267 inline vector3d<T> vecRotate(const vector3d<T> &Vector) const
00268 {
00269 return vector3d<T>(
00270 Vector.X*M[0] + Vector.Y*M[3] + Vector.Z*M[6],
00271 Vector.X*M[1] + Vector.Y*M[4] + Vector.Z*M[7],
00272 Vector.X*M[2] + Vector.Y*M[5] + Vector.Z*M[8]
00273 );
00274 }
00275
00276 inline vector3d<T> vecRotateInverse(const vector3d<T> &Vector) const
00277 {
00278 return vector3d<T>(
00279 Vector.X*M[0] + Vector.Y*M[1] + Vector.Z*M[2],
00280 Vector.X*M[3] + Vector.Y*M[4] + Vector.Z*M[5],
00281 Vector.X*M[6] + Vector.Y*M[7] + Vector.Z*M[8]
00282 );
00283 }
00284
00285 inline void clear()
00286 {
00287 memset(M, 0, sizeof(M));
00288 }
00289
00290
00291
00292
00293
00294
00295 inline matrix3<T>& reset()
00296 {
00297 M[0] = 1; M[3] = 0; M[6] = 0;
00298 M[1] = 0; M[4] = 1; M[7] = 0;
00299 M[2] = 0; M[5] = 0; M[8] = 1;
00300 return *this;
00301 }
00302
00303 inline void multiplySingleMatrix(const T (&other)[3])
00304 {
00305 T Result[3];
00306
00307 Result[0] = M[0]*other[0] + M[3]*other[1] + M[6]*other[2];
00308 Result[1] = M[1]*other[0] + M[4]*other[1] + M[7]*other[2];
00309 Result[2] = M[2]*other[0] + M[5]*other[1] + M[8]*other[2];
00310
00311 other[0] = Result[0]; other[1] = Result[1]; other[2] = Result[2];
00312 }
00313
00314 inline void matrixLookAt(const vector3d<T> &Position, const vector3d<T> &LookAt, const vector3d<T> &upVector)
00315 {
00316 vector3d<T> ZAxis = LookAt - Position;
00317 ZAxis.normalize();
00318
00319 vector3d<T> XAxis = upVector.cross(ZAxis);
00320 XAxis.normalize();
00321
00322 vector3d<T> YAxis = ZAxis.cross(XAxis);
00323
00324 M[0] = XAxis.X; M[3] = XAxis.Y; M[6] = XAxis.Z;
00325 M[1] = YAxis.X; M[4] = YAxis.Y; M[7] = YAxis.Z;
00326 M[2] = ZAxis.X; M[5] = ZAxis.Y; M[8] = ZAxis.Z;
00327 }
00328
00329 inline bool getInverse(matrix3<T> &InverseMat) const
00330 {
00331 const matrix3<T> &m = *this;
00332
00333 T d = ( m(0, 0) * m(1, 1) * m(2, 2) ) + ( m(0, 1) * m(1, 2) * m(2, 0) ) + ( m(0, 2) * m(1, 0) * m(2, 1) ) -
00334 ( m(2, 0) * m(1, 1) * m(0, 2) ) - ( m(2, 0) * m(1, 2) * m(0, 0) ) - ( m(2, 2) * m(1, 0) * m(0, 1) );
00335
00336 if (d == T(0))
00337 return false;
00338
00339 d = T(1) / d;
00340
00341 InverseMat(0, 0) = d * ( m(1, 1) * m(2, 2) - m(1, 2) * m(2, 1) );
00342 InverseMat(0, 1) = d * ( m(0, 2) * m(2, 1) - m(0, 1) * m(2, 2) );
00343 InverseMat(0, 2) = d * ( m(0, 1) * m(1, 2) - m(0, 2) * m(1, 1) );
00344 InverseMat(1, 0) = d * ( m(1, 2) * m(2, 0) - m(1, 0) * m(2, 2) );
00345 InverseMat(1, 1) = d * ( m(0, 0) * m(2, 2) - m(0, 2) * m(2, 0) );
00346 InverseMat(1, 2) = d * ( m(0, 0) * m(1, 1) - m(0, 1) * m(1, 0) );
00347 InverseMat(2, 0) = d * ( m(1, 0) * m(2, 1) - m(1, 1) * m(2, 0) );
00348 InverseMat(2, 1) = d * ( m(0, 1) * m(2, 0) - m(0, 0) * m(2, 1) );
00349 InverseMat(2, 2) = d * ( m(0, 0) * m(1, 1) - m(0, 1) * m(1, 0) );
00350
00351 return true;
00352 }
00353
00354 inline bool setInverse()
00355 {
00356 matrix3<T> Matrix;
00357
00358 if (getInverse(Matrix))
00359 {
00360 *this = Matrix;
00361 return true;
00362 }
00363
00364 return false;
00365 }
00366
00367 inline matrix3<T> getInverse() const
00368 {
00369 matrix3<T> Mat;
00370 getInverse(Mat);
00371 return Mat;
00372 }
00373
00374
00375
00376
00377
00378
00379 inline matrix3<T>& scale(const vector3d<T> &Vector)
00380 {
00381 matrix3<T> other;
00382
00383 other[0] = Vector.X;
00384 other[4] = Vector.Y;
00385 other[8] = Vector.Z;
00386
00387 return *this *= other;
00388 }
00389
00390
00391
00392
00393
00394
00395 inline matrix3<T>& rotate(const T &Angle, vector3d<T> Rotation)
00396 {
00397 matrix3<T> other;
00398
00399
00400 Rotation.normalize();
00401
00402
00403 T x = Rotation.X;
00404 T y = Rotation.Y;
00405 T z = Rotation.Z;
00406 T c = math::Cos(Angle);
00407 T s = math::Cos(Angle);
00408 T cc = T(1) - c;
00409
00410
00411 other[0] = x*x*cc+c; other[3] = x*y*cc-z*s; other[6] = x*z*cc+y*s;
00412 other[1] = y*x*cc+z*s; other[4] = y*y*cc+c; other[7] = y*z*cc-x*s;
00413 other[2] = x*z*cc-y*s; other[5] = y*z*cc+x*s; other[8] = z*z*cc+c;
00414
00415 return *this *= other;
00416 }
00417
00418 inline matrix3<T>& rotateX(const T &Angle)
00419 {
00420 matrix3<T> other;
00421 T c = math::Cos(Angle);
00422 T s = math::Sin(Angle);
00423
00424
00425 other[0] = 1; other[4] = 0; other[ 8] = 0;
00426 other[1] = 0; other[5] = c; other[ 9] = -s;
00427 other[2] = 0; other[6] = s; other[10] = c;
00428
00429 return *this *= other;
00430 }
00431
00432 inline matrix3<T>& rotateY(const T &Angle)
00433 {
00434 matrix3<T> other;
00435 T c = math::Cos(Angle);
00436 T s = math::Sin(Angle);
00437
00438
00439 other[0] = c; other[3] = 0; other[6] = s;
00440 other[1] = 0; other[4] = 1; other[7] = 0;
00441 other[2] = -s; other[5] = 0; other[8] = c;
00442
00443 return *this *= other;
00444 }
00445
00446 inline matrix3<T>& rotateZ(const T &Angle)
00447 {
00448 matrix3<T> other;
00449 T c = math::Cos(Angle);
00450 T s = math::Sin(Angle);
00451
00452
00453 other[0] = c; other[3] = -s; other[6] = 0;
00454 other[1] = s; other[4] = c; other[7] = 0;
00455 other[2] = 0; other[5] = 0; other[8] = 1;
00456
00457 return *this *= other;
00458 }
00459
00460 inline void rotateYXZ(const vector3df &Rotation)
00461 {
00462 rotateY(Rotation.Y);
00463 rotateX(Rotation.X);
00464 rotateZ(Rotation.Z);
00465 }
00466
00467 inline void rotateZXY(const vector3df &Rotation)
00468 {
00469 rotateZ(Rotation.Z);
00470 rotateX(Rotation.X);
00471 rotateY(Rotation.Y);
00472 }
00473
00474 inline void setRotation(vector3df Rotation, bool UseDegrees = true)
00475 {
00476 if (UseDegrees)
00477 Rotation = Rotation * M_PI / 180.0;
00478
00479 f64 cx = cos(Rotation.X);
00480 f64 sx = sin(Rotation.X);
00481 f64 cy = cos(Rotation.Y);
00482 f64 sy = sin(Rotation.Y);
00483 f64 cz = cos(Rotation.Z);
00484 f64 sz = sin(Rotation.Z);
00485
00486 f64 sxy = sx*sy;
00487 f64 cxy = cx*sy;
00488
00489 M[0] = (T)(cy*cz);
00490 M[1] = (T)(cy*sz);
00491 M[2] = (T)(-sy);
00492
00493 M[3] = (T)(sxy*cz - cx*sz);
00494 M[4] = (T)(sxy*sz + cx*cz);
00495 M[5] = (T)(sx*cy);
00496
00497 M[6] = (T)(cxy*cz + sx*sz);
00498 M[7] = (T)(cxy*sz - sx*cz);
00499 M[8] = (T)(cx*cy);
00500 }
00501
00502 inline void setInverseRotation(vector3df Rotation, bool UseDegrees = true)
00503 {
00504 if (UseDegrees)
00505 Rotation = Rotation * M_PI / 180.0;
00506
00507 f64 cx = cos(Rotation.X);
00508 f64 sx = sin(Rotation.X);
00509 f64 cy = cos(Rotation.Y);
00510 f64 sy = sin(Rotation.Y);
00511 f64 cz = cos(Rotation.Z);
00512 f64 sz = sin(Rotation.Z);
00513
00514 f64 sxy = sx*sy;
00515 f64 cxy = cx*sy;
00516
00517 M[0] = (T)(cy*cz);
00518 M[3] = (T)(cy*sz);
00519 M[6] = (T)(-sy);
00520
00521 M[1] = (T)(sxy*cz - cx*sz);
00522 M[4] = (T)(sxy*sz + cx*cz);
00523 M[7] = (T)(sx*cy);
00524
00525 M[2] = (T)(cxy*cz + sx*sz);
00526 M[5] = (T)(cxy*sz - sx*cz);
00527 M[8] = (T)(cx*cy);
00528 }
00529
00530 inline void setTextureRotation(const T &Degree)
00531 {
00532 T c = math::Cos(Degree);
00533 T s = math::Sin(Degree);
00534
00535 M[0] = c;
00536 M[1] = s;
00537 M[2] = T( -0.5 * ( c + s) + 0.5 );
00538
00539 M[3] = -s;
00540 M[4] = c;
00541 M[5] = T( -0.5 * (-s + c) + 0.5 );
00542 }
00543
00544
00545
00546 inline vector3d<T> getRow(s32 Position) const
00547 {
00548 switch (Position) {
00549 case 0:
00550 return vector3d<T>(M[0], M[3], M[6]);
00551 case 1:
00552 return vector3d<T>(M[1], M[4], M[7]);
00553 case 2:
00554 return vector3d<T>(M[2], M[5], M[8]);
00555 }
00556 return vector3d<T>();
00557 }
00558
00559 inline vector3d<T> getColumn(s32 Position) const
00560 {
00561 switch (Position) {
00562 case 0:
00563 return vector3d<T>(M[0], M[1], M[2]);
00564 case 1:
00565 return vector3d<T>(M[3], M[4], M[5]);
00566 case 2:
00567 return vector3d<T>(M[6], M[7], M[8]);
00568 }
00569 return vector3d<T>();
00570 }
00571
00572 inline void setScale(const vector3d<T> &Scale)
00573 {
00574 M[0] = Scale.X; M[4] = Scale.Y; M[8] = Scale.Z;
00575 }
00576 inline vector3d<T> getScale() const
00577 {
00578 return vector3d<T>(M[0], M[5], M[10]);
00579 }
00580
00581 inline vector3d<T> getRotation() const
00582 {
00583 const matrix3<T> &Mat = *this;
00584
00585 T Y = -(T)asin(Mat(0, 2));
00586 T C = (T)cos(Y);
00587 T rotx, roty, X, Z;
00588
00589 Y *= (T)math::RAD64;
00590
00591 if (fabs(C) > math::ROUNDING_ERROR)
00592 {
00593 C = (T)(1.0 / C);
00594 rotx = Mat(2, 2) * C;
00595 roty = Mat(1, 2) * C;
00596 X = (T)(atan2(roty, rotx) * math::RAD64);
00597 rotx = Mat(0, 0) * C;
00598 roty = Mat(0, 1) * C;
00599 Z = (T)(atan2(roty, rotx) * math::RAD64);
00600 }
00601 else
00602 {
00603 X = 0;
00604 rotx = Mat(1, 1);
00605 roty = -Mat(1, 0);
00606 Z = atan2(roty, rotx) * math::RAD64;
00607 }
00608
00609 if (X < 0) X += 360;
00610 if (Y < 0) Y += 360;
00611 if (Z < 0) Z += 360;
00612
00613 return vector3d<T>(X, Y, Z);
00614 }
00615
00616 inline matrix3<T> getTransposed() const
00617 {
00618 matrix3<T> Mat;
00619 getTransposed(Mat);
00620 return Mat;
00621 }
00622
00623 inline void getTransposed(matrix3<T> &other) const
00624 {
00625 other[0] = M[0]; other[3] = M[1]; other[6] = M[2];
00626 other[1] = M[3]; other[4] = M[4]; other[7] = M[5];
00627 other[2] = M[6]; other[5] = M[7]; other[8] = M[8];
00628 }
00629
00630 inline matrix3<T> interpolate(const matrix3<T> &other, f32 seek) const
00631 {
00632 matrix3<T> Mat;
00633
00634 for (s32 i = 0; i < 9; ++i)
00635 Mat.M[i] = M[i] + (other.M[i] - M[i]) * seek;
00636
00637 return Mat;
00638 }
00639
00640 inline bool isIdentity() const
00641 {
00642 for (s32 i = 0, j; i < 3; ++i)
00643 {
00644 for (j = 0; j < 3; ++j)
00645 {
00646 if ( ( i != j && !math::Equal((*this)(i, j), 0.0f) ) ||
00647 ( i == j && !math::Equal((*this)(i, j), 1.0f) ) )
00648 {
00649 return false;
00650 }
00651 }
00652 }
00653
00654 return true;
00655 }
00656
00657 inline const T* getArray() const
00658 {
00659 return M;
00660 }
00661
00662 inline T* getArray()
00663 {
00664 return M;
00665 }
00666
00667 template <typename B> inline matrix3<B> cast() const
00668 {
00669 B other[9];
00670
00671 for (s32 i = 0; i < 9; ++i)
00672 other[i] = static_cast<B>(M[i]);
00673
00674 return matrix3<B>(other);
00675 }
00676
00677 private:
00678
00679
00680
00681
00682
00683
00684
00685 T M[9];
00686
00687 };
00688
00689 typedef matrix3<f32> matrix3f;
00690 typedef matrix3<f64> matrix3d;
00691
00692
00693 }
00694
00695 }
00696
00697
00698 #endif
00699
00700
00701
00702