Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef SquareMatrix3H
00033 #define SquareMatrix3H
00034
00035 #include <zeusmath/System/Interfaces/ISquareMatrix3.hpp>
00036 #include <zeusmath/Geometry/Vector3D.h>
00037
00038
00039 #define SQUAREMATRIX3_DIMENSIONS 3
00040
00041
00042 BEGIN_NAMESPACE_Zeus
00043
00044
00045
00051
00052 zeusmath_class TSquareMatrix3 : public ISquareMatrix3
00053 {
00054 public:
00055 TSquareMatrix3(const Float& f11, const Float& f12, const Float& f13,
00056 const Float& f21, const Float& f22, const Float& f23,
00057 const Float& f31, const Float& f32, const Float& f33);
00058
00060 inline TSquareMatrix3() { initAsZeroMatrix(); }
00061
00063 inline TSquareMatrix3(const TSquareMatrix3& rMatrix) { assign(rMatrix); }
00064
00066 inline TSquareMatrix3(const ISquareMatrix3& rMatrix) { assign(rMatrix); }
00067
00069 inline TSquareMatrix3(const IMatrix& rMatrix) { assign(rMatrix); }
00070
00072 virtual inline ~TSquareMatrix3() { }
00073
00074
00075 virtual void MQUALIFIER setValues(const Float& f11, const Float& f12, const Float& f13,
00076 const Float& f21, const Float& f22, const Float& f23,
00077 const Float& f31, const Float& f32, const Float& f33);
00078 virtual void MQUALIFIER initAsRotationXMatrix(const IAngle& rAngle);
00079 virtual void MQUALIFIER initAsRotationYMatrix(const IAngle& rAngle);
00080 virtual void MQUALIFIER initAsRotationZMatrix(const IAngle& rAngle);
00081
00082
00083 virtual void MQUALIFIER assign(const IMatrix& rMatrix);
00084 virtual Float MQUALIFIER calcDeterminant() const;
00085 virtual bool MQUALIFIER calcInverse(IMatrix& rInverseMatrix) const;
00086 virtual void MQUALIFIER calcTransposed(IMatrix& rTransposedMatrix) const;
00087 virtual bool MQUALIFIER equals(const IMatrix& rMatrix, Float fPrecision = FLOAT_PRECISION) const;
00088 virtual Float MQUALIFIER getCell(Int iRow, Int iColumn, bool* pbError = NULL) const;
00089 virtual bool MQUALIFIER getRow(Int iRow, IVector& rVector) const;
00090 virtual bool MQUALIFIER getColumn(Int iColumn, IVector& rVector) const;
00091 virtual bool MQUALIFIER getDiagonalVector(IVector& rDiagVector) const;
00092 virtual Int MQUALIFIER getRowCount() const;
00093 virtual Int MQUALIFIER getColumnCount() const;
00094 virtual void MQUALIFIER initAsIdentityMatrix();
00095 virtual void MQUALIFIER initAsZeroMatrix();
00096 virtual bool MQUALIFIER invert();
00097 virtual bool MQUALIFIER isIdentityMatrix() const;
00098 virtual bool MQUALIFIER isInvertible() const;
00099 virtual bool MQUALIFIER isSquaredMatrix() const;
00100 virtual bool MQUALIFIER isZeroMatrix() const;
00101 virtual bool MQUALIFIER setCell(Int iRow, Int iColumn, const Float& rValue);
00102 virtual bool MQUALIFIER setRow(Int iRow, const IVector& rVector);
00103 virtual bool MQUALIFIER setColumn(Int iColumn, const IVector& rVector);
00104 virtual void MQUALIFIER setDiagonalValue(const Float& fValue);
00105 virtual void MQUALIFIER setDiagonalVector(const IVector& rDiagVector);
00106 virtual Retval MQUALIFIER setDimensions(Int iRows, Int iColumns);
00107 virtual bool MQUALIFIER swapCells(Int iRow1, Int iColumn1, Int iRow2, Int iColumn2);
00108 virtual void MQUALIFIER transpose();
00109 virtual Float MQUALIFIER getEntropy() const;
00110 virtual void MQUALIFIER addConstant(Float fConstant);
00111 virtual void MQUALIFIER multiplyConstant(Float fConstant);
00112
00113
00114 TSquareMatrix3 operator+(const Float& f) const;
00115 TSquareMatrix3 operator-(const Float& f) const;
00116 TVector3D operator*(const IVector3D& rVector) const;
00117 TSquareMatrix3 operator*(const TSquareMatrix3& rMatrix) const;
00118 TSquareMatrix3 operator*(const Float& f) const;
00119 TSquareMatrix3 operator/(const Float& f) const;
00120 const TSquareMatrix3& operator+=(const Float& f);
00121 const TSquareMatrix3& operator-=(const Float& f);
00122 const TSquareMatrix3& operator*=(const Float& f);
00123 const TSquareMatrix3& operator/=(const Float& f);
00124
00125
00126 const TSquareMatrix3& operator=(const IMatrix& rMatrix);
00127 const TSquareMatrix3& operator=(const TSquareMatrix3& rMatrix);
00128
00129
00130 bool operator==(const IMatrix& rMatrix) const;
00131 bool operator!=(const IMatrix& rMatrix) const;
00132
00133
00134
00136 static inline const TSquareMatrix3& getZeroMatrix() { return m_ZeroMatrix; }
00137
00139 static inline const TSquareMatrix3& getIdentityMatrix() { return m_IdentityMatrix; }
00140
00141 private:
00142
00148
00149 static inline bool isValidRowColumn(Int iValue)
00150 {
00151 return iValue >= 0 && iValue < SQUAREMATRIX3_DIMENSIONS;
00152 }
00153
00154
00161
00162 static inline bool areValidRowAndColumn(Int iRow, Int iColumn)
00163 {
00164 return isValidRowColumn(iRow) && isValidRowColumn(iColumn);
00165 }
00166
00167
00174
00175 inline const Float& getCellNoChecks(Int iRow, Int iColumn) const
00176 {
00177 return m_fCells[iRow][iColumn];
00178 }
00179
00180 private:
00182 Float m_fCells[SQUAREMATRIX3_DIMENSIONS][SQUAREMATRIX3_DIMENSIONS];
00183
00185 static const TSquareMatrix3 m_ZeroMatrix;
00186 static const TSquareMatrix3 m_IdentityMatrix;
00187 };
00188
00189
00190
00197
00198 inline TSquareMatrix3 TSquareMatrix3::operator-(const Float& f) const
00199 {
00200 TSquareMatrix3 mRetval(*this);
00201 mRetval.addConstant(-f);
00202 return mRetval;
00203 }
00204
00205
00213
00214 inline TSquareMatrix3 TSquareMatrix3::operator/(const Float& f) const
00215 {
00216 TSquareMatrix3 mRetval(*this);
00217 mRetval.multiplyConstant(1/f);
00218 return mRetval;
00219 }
00220
00221
00228
00229 inline const TSquareMatrix3& TSquareMatrix3::operator+=(const Float& f)
00230 {
00231 addConstant(f);
00232 return *this;
00233 }
00234
00235
00242
00243 inline const TSquareMatrix3& TSquareMatrix3::operator-=(const Float& f)
00244 {
00245 addConstant(-f);
00246 return *this;
00247 }
00248
00249
00257
00258 inline const TSquareMatrix3& TSquareMatrix3::operator*=(const Float& f)
00259 {
00260 multiplyConstant(f);
00261 return *this;
00262 }
00263
00264
00272
00273 inline const TSquareMatrix3& TSquareMatrix3::operator/=(const Float& f)
00274 {
00275 multiplyConstant(1/f);
00276 return *this;
00277 }
00278
00279
00286
00287 inline const TSquareMatrix3& TSquareMatrix3::operator=(const IMatrix& rMatrix)
00288 {
00289 assign(rMatrix);
00290 return *this;
00291 }
00292
00293
00300
00301 inline const TSquareMatrix3& TSquareMatrix3::operator=(const TSquareMatrix3& rMatrix)
00302 {
00303 ::memcpy(m_fCells, rMatrix.m_fCells, sizeof(m_fCells));
00304 return *this;
00305 }
00306
00307
00314
00315 inline bool TSquareMatrix3::operator==(const IMatrix& rMatrix) const
00316 {
00317 return equals(rMatrix);
00318 }
00319
00320
00328
00329 inline bool TSquareMatrix3::operator!=(const IMatrix& rMatrix) const
00330 {
00331 return !equals(rMatrix);
00332 }
00333
00334
00337
00338 inline bool MQUALIFIER TSquareMatrix3::getDiagonalVector(IVector& rDiagVector) const
00339 {
00340 rDiagVector.setDimension(3);
00341 rDiagVector.setComponent(0, m_fCells[0][0]);
00342 rDiagVector.setComponent(1, m_fCells[1][1]);
00343 rDiagVector.setComponent(2, m_fCells[2][2]);
00344 return true;
00345 }
00346
00347
00350
00351 inline Int MQUALIFIER TSquareMatrix3::getRowCount() const
00352 {
00353 return 3;
00354 }
00355
00356
00359
00360 inline Int MQUALIFIER TSquareMatrix3::getColumnCount() const
00361 {
00362 return 3;
00363 }
00364
00365
00368
00369 inline void MQUALIFIER TSquareMatrix3::initAsIdentityMatrix()
00370 {
00371 assign(getIdentityMatrix());
00372 }
00373
00374
00377
00378 inline void MQUALIFIER TSquareMatrix3::initAsZeroMatrix()
00379 {
00380 assign(getZeroMatrix());
00381 }
00382
00383
00386
00387 inline bool MQUALIFIER TSquareMatrix3::isIdentityMatrix() const
00388 {
00389 return equals(getIdentityMatrix());
00390 }
00391
00392
00395
00396 inline bool MQUALIFIER TSquareMatrix3::isInvertible() const
00397 {
00398 return calcDeterminant() != 0;
00399 }
00400
00401
00404
00405 inline bool MQUALIFIER TSquareMatrix3::isSquaredMatrix() const
00406 {
00407 return true;
00408 }
00409
00410
00413
00414 inline bool MQUALIFIER TSquareMatrix3::isZeroMatrix() const
00415 {
00416 return equals(getZeroMatrix());
00417 }
00418
00419
00422
00423 inline void MQUALIFIER TSquareMatrix3::setDiagonalValue(const Float& fValue)
00424 {
00425 for (Int iRowColumn = 0; iRowColumn < SQUAREMATRIX3_DIMENSIONS; ++iRowColumn)
00426 {
00427 setCell(iRowColumn, iRowColumn, fValue);
00428 }
00429 }
00430
00431
00434
00435 inline void MQUALIFIER TSquareMatrix3::setDiagonalVector(const IVector& rDiagVector)
00436 {
00437 m_fCells[0][0] = rDiagVector.getComponent(0);
00438 m_fCells[1][1] = rDiagVector.getComponent(1);
00439 m_fCells[2][2] = rDiagVector.getComponent(2);
00440 }
00441
00442
00445
00446 inline Retval MQUALIFIER TSquareMatrix3::setDimensions(Int , Int )
00447 {
00448 return RET_REQUEST_FAILED;
00449 }
00450
00451
00452
00453
00461
00462 inline TSquareMatrix3 operator*(const Float& f, const ISquareMatrix3& rMatrix)
00463 {
00464 return TSquareMatrix3(rMatrix) * f;
00465 }
00466
00467
00475
00476 inline TSquareMatrix3 operator+(const Float& f, const ISquareMatrix3& rMatrix)
00477 {
00478 return TSquareMatrix3(rMatrix) + f;
00479 }
00480
00481 END_NAMESPACE_Zeus
00482
00483 #endif
00484