00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00021 #ifndef _Matrix_hpp
00022 #define _Matrix_hpp
00023
00024 #include<ImLib3D/Vect3D.hpp>
00025
00027
00030 class Matrix
00031 {
00032 float data[3][3];
00033 public:
00034 float Cofactor(int i,int j) const;
00035 public:
00036 Vect3Df operator*(const Vect3Df &) const;
00037 Matrix operator*( const Matrix &other) const;
00038 void operator*=(const Matrix &other){*this=(*this)*other;}
00039 Matrix operator+( const Matrix &other) const;
00040 Matrix operator-( const Matrix &other) const;
00041 void Inverse();
00042 void Transpose();
00043 float MaxElement();
00044 float operator()(int i,int j) const {return data[i][j];}
00045 float &operator()(int i,int j) {return data[i][j];}
00046 void SetToIdentity(){SetToDiagonal(1,1,1);}
00047 void SetToZero();
00048 void SetToDiagonal(float x,float y,float z)
00049 {
00050 SetToZero();
00051 data[0][0]=x;
00052 data[1][1]=y;
00053 data[2][2]=z;
00054 }
00055 bool operator==(const Matrix &other);
00056 bool operator!=(const Matrix &other){return !operator==(other);}
00057 void operator=(const Matrix &other);
00058 Matrix(const Matrix &other);
00059 Matrix(const float *initArray);
00060 Matrix(float m00,float m01,float m02,
00061 float m10,float m11,float m12,
00062 float m20,float m21,float m22);
00063 Matrix(){SetToZero();}
00064 };
00065
00066 Matrix operator*(float s,const Matrix &matrix);
00067 ostream& operator<< (ostream& s, const Matrix& matrix);
00068
00069 inline float Matrix::Cofactor(int i,int j) const
00070 {
00071 return
00072 data[(i+2)%3][(j+2)%3]*data[(i+1)%3][(j+1)%3]-
00073 data[(i+2)%3][(j+1)%3]*data[(i+1)%3][(j+2)%3] ;
00074 }
00075
00076 #endif // _Matrix_hpp