40 #ifndef _matrix3x3_cpp
41 #define _matrix3x3_cpp
43 #include "matrix3x3.h"
47 #include "btBulletDynamicsCommon.h"
48 #include <OgreMatrix3.h>
116 Matrix3x3 ZMat(Cos,-Sin,0.0,Sin,Cos,0.0,0.0,0.0,1.0);
120 Matrix3x3 YMat(Cos,0.0,Sin,0.0,1.0,0.0,-Sin,0.0,Cos);
124 Matrix3x3 XMat(1.0,0.0,0.0,0.0,Cos,-Sin,0.0,Sin,Cos);
126 *
this = ZMat * (YMat * XMat);
132 if(Dist ==
Real(0.0))
135 Real XS = Rot.
X * Sc, YS = Rot.
Y * Sc, ZS = Rot.
Z * Sc;
136 Real WX = Rot.
W * XS, WY = Rot.
W * YS, WZ = Rot.
W * ZS;
137 Real XX = Rot.
X * XS, XY = Rot.
X * YS, XZ = Rot.
X * ZS;
138 Real YY = Rot.
Y * YS, YZ = Rot.
Y * ZS, ZZ = Rot.
Z * ZS;
140 XY + WZ,
Real(1.0) - (XX + ZZ), YZ - WX,
141 XZ - WY, YZ + WX,
Real(1.0) - (XX + YY));
148 Real OneMinusCos = 1.0 - Cos;
149 Real X2 = Axis.
X * Axis.
X;
150 Real Y2 = Axis.
Y * Axis.
Y;
151 Real Z2 = Axis.
Z * Axis.
Z;
152 Real XYM = Axis.
X * Axis.
Y * OneMinusCos;
153 Real XZM = Axis.
X * Axis.
Z * OneMinusCos;
154 Real YZM = Axis.
Y * Axis.
Z * OneMinusCos;
155 Real XSin = Axis.
X * Sin;
156 Real YSin = Axis.
Y * Sin;
157 Real ZSin = Axis.
Z * Sin;
159 Matrix[0][0] = X2 * OneMinusCos + Cos;
160 Matrix[0][1] = XYM - ZSin;
161 Matrix[0][2] = XZM + YSin;
162 Matrix[1][0] = XYM + ZSin;
163 Matrix[1][1] = Y2 * OneMinusCos + Cos;
164 Matrix[1][2] = YZM - XSin;
165 Matrix[2][0] = XZM - YSin;
166 Matrix[2][1] = YZM + XSin;
167 Matrix[2][2] = Z2 * OneMinusCos + Cos;
190 Real Cofactor10 = Matrix[1][2] * Matrix[2][0] - Matrix[1][0] * Matrix[2][2];
191 Real Cofactor20 = Matrix[1][0] * Matrix[2][1] - Matrix[1][1] * Matrix[2][0];
193 Real Det = Matrix[0][0] * Cofactor00 + Matrix[0][1] * Cofactor10 + Matrix[0][2] * Cofactor20;
203 if (Trace >
Real(0.0))
206 Ret.
W = (Sc *
Real(0.5));
209 Ret.
X = ( (Matrix[2][1] - Matrix[1][2]) * Sc );
210 Ret.
Y = ( (Matrix[0][2] - Matrix[2][0]) * Sc );
211 Ret.
Z = ( (Matrix[1][0] - Matrix[0][1]) * Sc );
215 int I = Matrix[0][0] < Matrix[1][1] ?
216 ( Matrix[1][1] < Matrix[2][2] ? 2 : 1 ) :
217 ( Matrix[0][0] < Matrix[2][2] ? 2 : 0 );
222 Ret[I] = Sc *
Real(0.5);
225 Ret[J] = ( Matrix[J][I] + Matrix[I][J] ) * Sc;
226 Ret[K] = ( Matrix[K][I] + Matrix[I][K] ) * Sc;
227 Ret[3] = ( Matrix[K][J] - Matrix[J][K] ) * Sc;
234 btVector3 Col1 = temp.getColumn(0);
235 btVector3 Col2 = temp.getColumn(1);
236 btVector3 Col3 = temp.getColumn(2);
256 Ogre::Vector3 Col1 = temp.GetColumn(0);
257 Ogre::Vector3 Col2 = temp.GetColumn(1);
258 Ogre::Vector3 Col3 = temp.GetColumn(2);
281 for(
Whole Row = 0 ; Row < 3 ; ++Row )
283 for(
Whole Col = 0 ; Col < 3 ; ++Col )
294 for(
Whole Row = 0 ; Row < 3 ; ++Row )
296 for(
Whole Col = 0 ; Col < 3 ; ++Col )
311 for(
Whole Row = 0 ; Row < 3 ; ++Row )
313 for(
Whole Col = 0 ; Col < 3 ; ++Col )
324 for(
Whole Row = 0 ; Row < 3 ; ++Row )
326 for(
Whole Col = 0 ; Col < 3 ; ++Col )
337 for(
Whole Row = 0 ; Row < 3 ; ++Row )
339 for(
Whole Col = 0 ; Col < 3 ; ++Col )
352 for(
Whole Row = 0 ; Row < 3 ; ++Row )
354 for(
Whole Col = 0 ; Col < 3 ; ++Col )
364 for(
Whole Row = 0 ; Row < 3 ; ++Row )
366 for(
Whole Col = 0 ; Col < 3 ; ++Col )
376 (*this) = (*this) * Other;
397 for(
Whole Row = 0 ; Row < 3 ; ++Row )
399 for(
Whole Col = 0 ; Col < 3 ; ++Col )
409 for(
Whole Row = 0 ; Row < 3 ; ++Row )
411 for(
Whole Col = 0 ; Col < 3 ; ++Col )
413 Matrix[Row][Col] *= Scaler;
424 for(
Whole Row = 0 ; Row < 3 ; ++Row )
426 for(
Whole Col = 0 ; Col < 3 ; ++Col )
436 for(
Whole Row = 0 ; Row < 3 ; ++Row )
438 for(
Whole Col = 0 ; Col < 3 ; ++Col )
452 for(
Whole Row = 0 ; Row < 3 ; Row++ )
454 for(
Whole Col = 0 ; Col < 3 ; Col++ )
462 return Matrix3x3(
CoFactor(1,1,2,2),
CoFactor(0,2,2,1),
CoFactor(0,1,1,2),
463 CoFactor(1,2,2,0),
CoFactor(0,0,2,2),
CoFactor(0,2,1,0),
464 CoFactor(1,0,2,1),
CoFactor(0,1,2,0),
CoFactor(0,0,1,1));
471 Ret.
Matrix[0][1] = Matrix[0][2] * Matrix[2][1] - Matrix[0][1] * Matrix[2][2];
472 Ret.
Matrix[0][2] = Matrix[0][1] * Matrix[1][2] - Matrix[0][2] * Matrix[1][1];
473 Ret.
Matrix[1][0] = Matrix[1][2] * Matrix[2][0] - Matrix[1][0] * Matrix[2][2];
474 Ret.
Matrix[1][1] = Matrix[0][0] * Matrix[2][2] - Matrix[0][2] * Matrix[2][0];
475 Ret.
Matrix[1][2] = Matrix[0][2] * Matrix[1][0] - Matrix[0][0] * Matrix[1][2];
476 Ret.
Matrix[2][0] = Matrix[1][0] * Matrix[2][1] - Matrix[1][1] * Matrix[2][0];
477 Ret.
Matrix[2][1] = Matrix[0][1] * Matrix[2][0] - Matrix[0][0] * Matrix[2][1];
478 Ret.
Matrix[2][2] = Matrix[0][0] * Matrix[1][1] - Matrix[0][1] * Matrix[1][0];
480 Real Det = Matrix[0][0] * Ret.
Matrix[0][0] + Matrix[0][1] * Ret.
Matrix[1][0] + Matrix[0][2] * Ret.
Matrix[2][0];
485 Real InvDet = 1.0 / Det;
486 for(
Whole Row = 0 ; Row < 3 ; Row++)
488 for(
Whole Col = 0 ; Col < 3 ; Col++)
489 Ret.
Matrix[Row][Col] *= InvDet;
517 Test = Matrix[0][1] * Matrix[0][1] + Matrix[1][1] * Matrix[1][1] + Matrix[2][1] * Matrix[2][1];
520 Test = Matrix[0][2] * Matrix[0][2] + Matrix[1][2] * Matrix[1][2] + Matrix[2][2] * Matrix[2][2];