Wm4Matrix2.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef WM4MATRIX2_H
00018 #define WM4MATRIX2_H
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044 #include "Wm4FoundationLIB.h"
00045 #include "Wm4Vector2.h"
00046
00047 namespace Wm4
00048 {
00049
00050 template <class Real>
00051 class Matrix2
00052 {
00053 public:
00054
00055
00056 Matrix2 (bool bZero = true);
00057
00058
00059 Matrix2 (const Matrix2& rkM);
00060
00061
00062 Matrix2 (Real fM00, Real fM01, Real fM10, Real fM11);
00063
00064
00065
00066
00067
00068 Matrix2 (const Real afEntry[4], bool bRowMajor);
00069
00070
00071
00072
00073 Matrix2 (const Vector2<Real>& rkU, const Vector2<Real>& rkV,
00074 bool bColumns);
00075 Matrix2 (const Vector2<Real>* akV, bool bColumns);
00076
00077
00078 Matrix2 (Real fM00, Real fM11);
00079
00080
00081 Matrix2 (Real fAngle);
00082
00083
00084 Matrix2 (const Vector2<Real>& rkU, const Vector2<Real>& rkV);
00085
00086
00087 void MakeZero ();
00088 void MakeIdentity ();
00089 void MakeDiagonal (Real fM00, Real fM11);
00090 void FromAngle (Real fAngle);
00091 void MakeTensorProduct (const Vector2<Real>& rkU,
00092 const Vector2<Real>& rkV);
00093
00094
00095 operator const Real* () const;
00096 operator Real* ();
00097 const Real* operator[] (int iRow) const;
00098 Real* operator[] (int iRow);
00099 Real operator() (int iRow, int iCol) const;
00100 Real& operator() (int iRow, int iCol);
00101 void SetRow (int iRow, const Vector2<Real>& rkV);
00102 Vector2<Real> GetRow (int iRow) const;
00103 void SetColumn (int iCol, const Vector2<Real>& rkV);
00104 Vector2<Real> GetColumn (int iCol) const;
00105 void GetColumnMajor (Real* afCMajor) const;
00106
00107
00108 Matrix2& operator= (const Matrix2& rkM);
00109
00110
00111 bool operator== (const Matrix2& rkM) const;
00112 bool operator!= (const Matrix2& rkM) const;
00113 bool operator< (const Matrix2& rkM) const;
00114 bool operator<= (const Matrix2& rkM) const;
00115 bool operator> (const Matrix2& rkM) const;
00116 bool operator>= (const Matrix2& rkM) const;
00117
00118
00119 Matrix2 operator+ (const Matrix2& rkM) const;
00120 Matrix2 operator- (const Matrix2& rkM) const;
00121 Matrix2 operator* (const Matrix2& rkM) const;
00122 Matrix2 operator* (Real fScalar) const;
00123 Matrix2 operator/ (Real fScalar) const;
00124 Matrix2 operator- () const;
00125
00126
00127 Matrix2& operator+= (const Matrix2& rkM);
00128 Matrix2& operator-= (const Matrix2& rkM);
00129 Matrix2& operator*= (Real fScalar);
00130 Matrix2& operator/= (Real fScalar);
00131
00132
00133 Vector2<Real> operator* (const Vector2<Real>& rkV) const;
00134
00135
00136 Matrix2 Transpose () const;
00137 Matrix2 TransposeTimes (const Matrix2& rkM) const;
00138 Matrix2 TimesTranspose (const Matrix2& rkM) const;
00139 Matrix2 Inverse () const;
00140 Matrix2 Adjoint () const;
00141 Real Determinant () const;
00142 Real QForm (const Vector2<Real>& rkU,
00143 const Vector2<Real>& rkV) const;
00144
00145
00146
00147
00148
00149 void ToAngle (Real& rfAngle) const;
00150 void Orthonormalize ();
00151
00152
00153
00154
00155
00156
00157 void EigenDecomposition (Matrix2& rkRot, Matrix2& rkDiag) const;
00158
00159 WM4_FOUNDATION_ITEM static const Matrix2 ZERO;
00160 WM4_FOUNDATION_ITEM static const Matrix2 IDENTITY;
00161
00162 private:
00163
00164 int CompareArrays (const Matrix2& rkM) const;
00165
00166
00167 Real m_afEntry[4];
00168 };
00169
00170
00171 template <class Real>
00172 Matrix2<Real> operator* (Real fScalar, const Matrix2<Real>& rkM);
00173
00174
00175 template <class Real>
00176 Vector2<Real> operator* (const Vector2<Real>& rkV, const Matrix2<Real>& rkM);
00177
00178 }
00179
00180 #include "Wm4Matrix2.inl"
00181
00182 namespace Wm4
00183 {
00184 typedef Matrix2<float> Matrix2f;
00185 typedef Matrix2<double> Matrix2d;
00186 }
00187
00188 #endif