00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef MGCMATRIX3_H
00014 #define MGCMATRIX3_H
00015
00016 #include "MgcVector3.h"
00017
00018 namespace Mgc {
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 class UTILITIES_API MAGICFM Matrix3
00037 {
00038 public:
00039
00040 Matrix3 ();
00041 Matrix3 (const Real aafEntry[3][3]);
00042 Matrix3 (const Matrix3& rkMatrix);
00043 Matrix3 (Real fEntry00, Real fEntry01, Real fEntry02,
00044 Real fEntry10, Real fEntry11, Real fEntry12,
00045 Real fEntry20, Real fEntry21, Real fEntry22);
00046
00047
00048 Real* operator[] (int iRow) const;
00049 operator Real* ();
00050 Vector3 GetColumn (int iCol) const;
00051
00052
00053 Matrix3& operator= (const Matrix3& rkMatrix);
00054 bool operator== (const Matrix3& rkMatrix) const;
00055 bool operator!= (const Matrix3& rkMatrix) const;
00056
00057
00058 Matrix3 operator+ (const Matrix3& rkMatrix) const;
00059 Matrix3 operator- (const Matrix3& rkMatrix) const;
00060 Matrix3 operator* (const Matrix3& rkMatrix) const;
00061 Matrix3 operator- () const;
00062
00063
00064 Vector3 operator* (const Vector3& rkVector) const;
00065
00066
00067 MAGICFM friend Vector3 operator* (const Vector3& rkVector,
00068 const Matrix3& rkMatrix);
00069
00070
00071 Matrix3 operator* (Real fScalar) const;
00072
00073
00074 MAGICFM friend Matrix3 operator* (Real fScalar, const Matrix3& rkMatrix);
00075
00076
00077 Matrix3 TransposeTimes (const Matrix3& rkM) const;
00078
00079
00080 Matrix3 TimesTranspose (const Matrix3& rkM) const;
00081
00082
00083 Matrix3 Transpose () const;
00084 bool Inverse (Matrix3& rkInverse, Real fTolerance = 1e-06f) const;
00085 Matrix3 Inverse (Real fTolerance = 1e-06f) const;
00086 Real Determinant () const;
00087
00088
00089
00090
00091
00092 static Matrix3 Slerp (Real fT, const Matrix3& rkR0, const Matrix3& rkR1);
00093
00094
00095 void SingularValueDecomposition (Matrix3& rkL, Vector3& rkS,
00096 Matrix3& rkR) const;
00097 void SingularValueComposition (const Matrix3& rkL,
00098 const Vector3& rkS, const Matrix3& rkR);
00099
00100
00101 void Orthonormalize ();
00102
00103
00104 void QDUDecomposition (Matrix3& rkQ, Vector3& rkD, Vector3& rkU) const;
00105
00106 Real SpectralNorm () const;
00107
00108
00109 void ToAxisAngle (Vector3& rkAxis, Real& rfRadians) const;
00110 void FromAxisAngle (const Vector3& rkAxis, Real fRadians);
00111
00112
00113
00114
00115 bool ToEulerAnglesXYZ (Real& rfYAngle, Real& rfPAngle,
00116 Real& rfRAngle) const;
00117 bool ToEulerAnglesXZY (Real& rfYAngle, Real& rfPAngle,
00118 Real& rfRAngle) const;
00119 bool ToEulerAnglesYXZ (Real& rfYAngle, Real& rfPAngle,
00120 Real& rfRAngle) const;
00121 bool ToEulerAnglesYZX (Real& rfYAngle, Real& rfPAngle,
00122 Real& rfRAngle) const;
00123 bool ToEulerAnglesZXY (Real& rfYAngle, Real& rfPAngle,
00124 Real& rfRAngle) const;
00125 bool ToEulerAnglesZYX (Real& rfYAngle, Real& rfPAngle,
00126 Real& rfRAngle) const;
00127 void FromEulerAnglesXYZ (Real fYAngle, Real fPAngle, Real fRAngle);
00128 void FromEulerAnglesXZY (Real fYAngle, Real fPAngle, Real fRAngle);
00129 void FromEulerAnglesYXZ (Real fYAngle, Real fPAngle, Real fRAngle);
00130 void FromEulerAnglesYZX (Real fYAngle, Real fPAngle, Real fRAngle);
00131 void FromEulerAnglesZXY (Real fYAngle, Real fPAngle, Real fRAngle);
00132 void FromEulerAnglesZYX (Real fYAngle, Real fPAngle, Real fRAngle);
00133
00134
00135 void EigenSolveSymmetric (Real afEigenvalue[3],
00136 Vector3 akEigenvector[3]) const;
00137
00138 static void TensorProduct (const Vector3& rkU, const Vector3& rkV,
00139 Matrix3& rkProduct);
00140
00141 static const Real EPSILON;
00142 static const Matrix3 ZERO;
00143 static const Matrix3 IDENTITY;
00144
00145 protected:
00146
00147 void Tridiagonal (Real afDiag[3], Real afSubDiag[3]);
00148 bool QLAlgorithm (Real afDiag[3], Real afSubDiag[3]);
00149
00150
00151 static const Real ms_fSvdEpsilon;
00152 static const int ms_iSvdMaxIterations;
00153 static void Bidiagonalize (Matrix3& kA, Matrix3& kL, Matrix3& kR);
00154 static void GolubKahanStep (Matrix3& kA, Matrix3& kL, Matrix3& kR);
00155
00156
00157 static Real MaxCubicRoot (Real afCoeff[3]);
00158
00159 Real m_aafEntry[3][3];
00160 };
00161
00162 #include "MgcMatrix3.inl"
00163
00164 }
00165
00166 #endif
00167
00168