Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

Matrix.hpp

Go to the documentation of this file.
00001 /*
00002  *  Copyright (C) 2005 L2TI Universite Paris-13
00003  *
00004  * This program is free software; you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License as published by
00006  * the Free Software Foundation; either version 2 of the License, or
00007  * (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
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

Generated on Fri Jun 17 13:36:05 2005 for ImLib3D by  doxygen 1.4.2