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
00033
00034
00035
00036
00037
00038
00039
00040 #ifndef __CXUTILS_MATH_MATRIX_H
00041 #define __CXUTILS_MATH_MATRIX_H
00042
00043 #include "cxutils/cxbase.h"
00044
00045 namespace CxUtils
00046 {
00053 class CX_UTILS_DLL Matrix
00054 {
00055 public:
00056 Matrix();
00057 Matrix(const Matrix& m);
00058 Matrix(const unsigned int rows,
00059 const unsigned int cols);
00060 Matrix(const unsigned int rows,
00061 const unsigned int cols,
00062 const double v);
00063 ~Matrix();
00064 int Create(const unsigned int rows,
00065 const unsigned int cols);
00066 int Create(const unsigned int rows,
00067 const unsigned int cols,
00068 const double v);
00069 int GetDeterminant(double& d) const;
00070 int GetMinor(const unsigned int row,
00071 const unsigned int col,
00072 Matrix& minor) const;
00073 int GetInverse(Matrix& i) const;
00074 static int GaussJordan(Matrix& a, Matrix& b);
00075 static int GaussJordan(const Matrix& a, const Matrix& b, Matrix& x);
00076 void Clear();
00077 void Destroy();
00078 void Print() const;
00079 inline bool IsSquare() const { return mRows == mCols; }
00080 inline unsigned int Rows() const { return mRows; }
00081 inline unsigned int Cols() const { return mCols; }
00082 static Matrix CreateRotationX(const double val,
00083 const bool degres = false);
00084 static Matrix CreateRotationY(const double val,
00085 const bool degres = false);
00086 static Matrix CreateRotationZ(const double val,
00087 const bool degres = false);
00088 static Matrix CreateScalingMatrix(const double x,
00089 const double y,
00090 const double z);
00091 static Matrix CreateTranslationMatrix(const double x,
00092 const double y,
00093 const double z);
00094 static void Transpose(const Matrix& original, Matrix& transpose);
00095 Matrix Inverse() const;
00096 Matrix Transpose() const;
00097 Matrix& operator=(const Matrix& m);
00098 Matrix& operator=(const double v);
00099 Matrix operator+(const Matrix& m) const;
00100 Matrix& operator+=(const Matrix& m);
00101 Matrix operator-(const Matrix& m) const;
00102 Matrix& operator-=(const Matrix& m);
00103 Matrix operator*(const Matrix& m) const;
00104 Matrix operator/(const Matrix& m) const;
00105 Matrix& operator*=(const Matrix& m);
00106 Matrix& operator/=(const Matrix& m);
00107 double* operator[](const unsigned int i);
00108 double* operator[](const unsigned int i) const;
00109 double& operator()(const unsigned int row, const unsigned int col);
00110 double operator()(const unsigned int row, const unsigned int col) const;
00111 protected:
00112 double *mpMatrix;
00113 unsigned int mRows;
00114 unsigned int mCols;
00115 unsigned int mSize;
00116 };
00117 }
00118
00119 #endif
00120