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