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

Affine3DTransform.hpp

Go to the documentation of this file.
00001 /* ImLib3D
00002  * Copyright (c) 2001, ULP-IPB Strasbourg.
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 (at
00007  * your option) any later version.
00008  * 
00009  * This program is distributed in the hope that it will be useful, but
00010  * WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * 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., 675 Mass Ave, Cambridge, MA 02139, USA.
00017  */
00018 #ifndef _Affine3DTransform_hpp
00019 #define _Affine3DTransform_hpp
00020  
00032 #include<ImLib3D/CppTools.hpp>
00033 #include<ImLib3D/Vect3D.hpp>
00034 #include<ImLib3D/ImLib3DFile.hpp>
00035 #include<ImLib3D/Matrix.hpp>
00036 
00037 
00039 
00040 class Affine3DTransform : public Streamable
00041 {
00042     friend void Affine3DTransform_Test();
00043     friend Affine3DTransform operator*(const Affine3DTransform& a1,const Affine3DTransform& a2);
00044 private:
00045     Matrix matrix;
00046     Vect3Df translation;
00047 public:
00049     Matrix GetMatrix() const {return matrix;}
00050     Vect3Df Translation() const {return translation;}
00051     double operator()(int i,int j) const {return matrix(i,j);}
00052     double operator()(int i) const {return translation(i);}
00053     void Set(const Matrix &_matrix,const Vect3Df &_translation){matrix=_matrix;translation=_translation;}
00054 
00056     Vect3Df operator()(const Vect3Df &x) const
00057     {
00058         return matrix*x+translation;
00059     }
00061     void Inverse();
00062 
00063     virtual ~Affine3DTransform(){;}
00064     Affine3DTransform()
00065     {
00066         Reset();
00067     }
00068 
00069     Affine3DTransform(const Vect3Df &_translation)
00070     {
00071         Reset();
00072         SetTranslation(_translation);
00073     }
00074     Affine3DTransform(float theta,const Vect3Df &direction,
00075                       const Vect3Df &center=Vect3Df(0,0,0))
00076     {
00077         Reset();
00078         SetRotation(theta,direction,center);
00079     }
00081     Affine3DTransform(const string &fname);
00082     virtual void Read( ImLib3DFile *file,xmlpp::Element *parentNode=NULL,xmlpp::Element *node=NULL)      ;
00083     virtual void Write(ImLib3DFile *file,xmlpp::Element *parentNode=NULL,xmlpp::Element *node=NULL) const;
00084     void Show()
00085     {
00086         cout << "matrix:" << endl;
00087         cout << matrix << endl;
00088         cout << "translation:" << endl;
00089         cout << translation << endl;
00090     }
00092     void Analyse();
00094     void Reset()
00095     {
00096         matrix.SetToIdentity();
00097         translation=Vect3Df(0,0,0);
00098     }
00100 
00109     void SetRotationX(float theta,const Vect3Df &center=Vect3Df(0,0,0));
00110     void SetRotationY(float theta,const Vect3Df &center=Vect3Df(0,0,0));
00111     void SetRotationZ(float theta,const Vect3Df &center=Vect3Df(0,0,0));
00112     void SetRotation (float theta,Vect3Df direction,
00113                       const Vect3Df &center=Vect3Df(0,0,0));
00114     void SetTranslation(const Vect3Df &_translation){translation=_translation;}
00115     void SetScale(float sx,float sy,float sz)
00116     {
00117         Reset();
00118         matrix(0,0)=sx;
00119         matrix(1,1)=sy;
00120         matrix(2,2)=sz;
00121     }
00122     void SetScale(const Vect3Df &scale){SetScale(scale.x, scale.y, scale.z);}
00124 
00125     Affine3DTransform operator*=(const Affine3DTransform& other);
00126     
00127 };
00128 extern Affine3DTransform operator*(const Affine3DTransform& a1,const Affine3DTransform& a2);
00129 
00130 
00131 
00132 #endif //_Affine3DTransform_hpp

Generated on Fri Jun 17 13:35:14 2005 for ImLib3D by  doxygen 1.4.2