19 #ifndef MIRTK_Matrix3x3_H 20 #define MIRTK_Matrix3x3_H 22 #include "mirtk/NumericsExport.h" 24 #include "mirtk/Vector3.h" 25 #include "mirtk/Math.h" 53 Matrix3x3 (
const double aafEntry[3][3]);
54 Matrix3x3 (
const Matrix3x3& rkMatrix);
55 Matrix3x3 (
double fEntry00,
double fEntry01,
double fEntry02,
56 double fEntry10,
double fEntry11,
double fEntry12,
57 double fEntry20,
double fEntry21,
double fEntry22);
60 double* operator[] (
int iRow);
61 const double* operator[] (
int iRow)
const;
63 Vector3 GetColumn (
int iCol)
const;
66 Matrix3x3& operator= (
const Matrix3x3& rkMatrix);
67 Matrix3x3& operator= (
double);
68 bool operator== (
const Matrix3x3& rkMatrix)
const;
69 bool operator!= (
const Matrix3x3& rkMatrix)
const;
72 Matrix3x3 &operator+=(
double);
73 Matrix3x3 &operator-=(
double);
74 Matrix3x3 &operator*=(
double);
75 Matrix3x3 &operator/=(
double);
77 Matrix3x3 operator+ (
double)
const;
78 Matrix3x3 operator- (
double)
const;
79 Matrix3x3 operator* (
double)
const;
80 Matrix3x3 operator/ (
double)
const;
82 Matrix3x3 &operator+=(
const Matrix3x3& rkMatrix);
83 Matrix3x3 &operator-=(
const Matrix3x3& rkMatrix);
84 Matrix3x3 &operator*=(
const Matrix3x3& rkMatrix);
85 Matrix3x3 &operator/=(
const Matrix3x3& rkMatrix);
87 Matrix3x3 operator+ (
const Matrix3x3& rkMatrix)
const;
88 Matrix3x3 operator- (
const Matrix3x3& rkMatrix)
const;
89 Matrix3x3 operator* (
const Matrix3x3& rkMatrix)
const;
90 Matrix3x3 operator/ (
const Matrix3x3& rkMatrix)
const;
91 Matrix3x3 operator- ()
const;
94 Vector3 operator* (
const Vector3& rkVector)
const;
97 friend Vector3 operator* (
const Vector3& rkVector,
98 const Matrix3x3& rkMatrix);
101 friend Matrix3x3 operator* (
double fScalar,
const Matrix3x3& rkMatrix);
104 Matrix3x3 Transpose ()
const;
105 bool Inverse (Matrix3x3& rkInverse,
double fTolerance = 1e-06)
const;
106 Matrix3x3 Inverse (
double fTolerance = 1e-06)
const;
107 double Determinant ()
const;
108 Matrix3x3 Adjoint()
const;
109 double Trace()
const;
112 void SingularValueDecomposition (Matrix3x3& rkL, Vector3& rkS,
113 Matrix3x3& rkR)
const;
114 void SingularValueComposition (
const Matrix3x3& rkL,
115 const Vector3& rkS,
const Matrix3x3& rkR);
118 void Orthonormalize ();
121 void QDUDecomposition (Matrix3x3& rkQ, Vector3& rkD,
132 Matrix3x3 PolarDecomposition()
const;
135 double RowNorm(
int)
const;
138 double ColNorm(
int)
const;
141 double MaxRowNorm()
const;
144 double MaxColNorm()
const;
146 double SpectralNorm ()
const;
149 void ToAxisAngle (Vector3& rkAxis,
double& rfRadians)
const;
150 void FromAxisAngle (
const Vector3& rkAxis,
double fRadians);
155 bool ToEulerAnglesXYZ (
double& rfYAngle,
double& rfPAngle,
double& rfRAngle)
const;
156 bool ToEulerAnglesXZY (
double& rfYAngle,
double& rfPAngle,
double& rfRAngle)
const;
157 bool ToEulerAnglesYXZ (
double& rfYAngle,
double& rfPAngle,
double& rfRAngle)
const;
158 bool ToEulerAnglesYZX (
double& rfYAngle,
double& rfPAngle,
double& rfRAngle)
const;
159 bool ToEulerAnglesZXY (
double& rfYAngle,
double& rfPAngle,
double& rfRAngle)
const;
160 bool ToEulerAnglesZYX (
double& rfYAngle,
double& rfPAngle,
double& rfRAngle)
const;
161 void FromEulerAnglesXYZ (
double fYAngle,
double fPAngle,
double fRAngle);
162 void FromEulerAnglesXZY (
double fYAngle,
double fPAngle,
double fRAngle);
163 void FromEulerAnglesYXZ (
double fYAngle,
double fPAngle,
double fRAngle);
164 void FromEulerAnglesYZX (
double fYAngle,
double fPAngle,
double fRAngle);
165 void FromEulerAnglesZXY (
double fYAngle,
double fPAngle,
double fRAngle);
166 void FromEulerAnglesZYX (
double fYAngle,
double fPAngle,
double fRAngle);
169 void EigenSolveSymmetric (
double afEigenvalue[3],
170 Vector3 akEigenvector[3])
const;
172 static void TensorProduct (
const Vector3& rkU,
const Vector3& rkV,
173 Matrix3x3& rkProduct);
175 MIRTK_Numerics_EXPORT
static const double EPSILON;
176 MIRTK_Numerics_EXPORT
static const Matrix3x3 ZERO;
177 MIRTK_Numerics_EXPORT
static const Matrix3x3 IDENTITY;
180 void Tridiagonal(
double afDiag[3],
double afSubDiag[3]);
181 bool QLAlgorithm(
double afDiag[3],
double afSubDiag[3]);
184 MIRTK_Numerics_EXPORT
static const double ms_fSvdEpsilon;
185 MIRTK_Numerics_EXPORT
static const int ms_iSvdMaxIterations;
186 static void Bidiagonalize (Matrix3x3& kA, Matrix3x3& kL,
188 static void GolubKahanStep (Matrix3x3& kA, Matrix3x3& kL,
192 static double MaxCubicRoot (
double afCoeff[3]);
196 double m_aafEntry[3][3];
204 inline double Matrix3x3::RowNorm(
int r)
const 206 return abs(m_aafEntry[r][0]) + abs(m_aafEntry[r][1]) + abs(m_aafEntry[r][2]);
210 inline double Matrix3x3::MaxRowNorm()
const 212 return max(max(RowNorm(0), RowNorm(1)), RowNorm(2));
216 inline double Matrix3x3::ColNorm(
int c)
const 218 return abs(m_aafEntry[0][c]) + abs(m_aafEntry[1][c]) + abs(m_aafEntry[2][c]);
222 inline double Matrix3x3::MaxColNorm()
const 224 return max(max(ColNorm(0), ColNorm(1)), ColNorm(2));
230 #endif // MIRTK_Matrix3x3_H
MIRTKCU_API bool operator==(const float1 &a, const float1 &b)
Check two 1D vectors for equality.