A.I.M.S


affinetransformation3d.h
Go to the documentation of this file.
1 /* This software and supporting documentation are distributed by
2  * Institut Federatif de Recherche 49
3  * CEA/NeuroSpin, Batiment 145,
4  * 91191 Gif-sur-Yvette cedex
5  * France
6  *
7  * This software is governed by the CeCILL-B license under
8  * French law and abiding by the rules of distribution of free software.
9  * You can use, modify and/or redistribute the software under the
10  * terms of the CeCILL-B license as circulated by CEA, CNRS
11  * and INRIA at the following URL "http://www.cecill.info".
12  *
13  * As a counterpart to the access to the source code and rights to copy,
14  * modify and redistribute granted by the license, users are provided only
15  * with a limited warranty and the software's author, the holder of the
16  * economic rights, and the successive licensors have only limited
17  * liability.
18  *
19  * In this respect, the user's attention is drawn to the risks associated
20  * with loading, using, modifying and/or developing or reproducing the
21  * software by the user in light of its specific status of free software,
22  * that may mean that it is complicated to manipulate, and that also
23  * therefore means that it is reserved for developers and experienced
24  * professionals having in-depth computer knowledge. Users are therefore
25  * encouraged to load and test the software's suitability as regards their
26  * requirements in conditions enabling the security of their systems and/or
27  * data to be ensured and, more generally, to use and operate it in the
28  * same conditions as regards security.
29  *
30  * The fact that you are presently reading this means that you have had
31  * knowledge of the CeCILL-B license and that you accept its terms.
32  */
33 
34 /*
35  * Non elastic AffineTransformation3d ( rotation + translation )
36  */
37 #ifndef AIMS_TRANSFORMATION_AFFINETRANSFORMATION3D_H
38 #define AIMS_TRANSFORMATION_AFFINETRANSFORMATION3D_H
39 
42 #include <aims/data/data.h>
43 #include <aims/math/mathelem.h>
44 #include <iostream>
45 
46 namespace aims
47 {
48  class AffineTransformation3d;
49  class PythonHeader;
50  class Quaternion;
51 
53  ( const AffineTransformation3d &AffineTransformation3d,
54  const Point3df & pmin1, const Point3df & pmax1, Point3df & pmin2,
55  Point3df & pmax2 );
56 
57  std::ostream&
58  operator << ( std::ostream& os,
59  const AffineTransformation3d& thing );
60 
61 //-----------------------------------------------------------------------------
62 
63  //--------------------------//
64  // AffineTransformation3d //
65 //--------------------------//
66 //-----------------------------------------------------------------------------
106 {
107 public:
108 
113  AffineTransformation3d( const std::vector<float> & mat );
117  virtual ~AffineTransformation3d();
119  virtual AffineTransformation3d &operator = ( const std::vector<float> & mat );
120  virtual AffineTransformation3d &operator = ( const carto::Object mat );
121  virtual AffineTransformation3d &operator = ( const aims::Quaternion & quat );
122 
123  virtual bool operator == ( const AffineTransformation3d & );
124 
126  // AffineTransformation3d & operator += ( const AffineTransformation3d & trans );
127  virtual AffineTransformation3d operator - () const;
128 
130  const aims::PythonHeader* header() const { return _header; }
131  void setHeader( aims::PythonHeader* ph );
132 
133  inline Point3df& translation() { return _translation; }
134  inline const Point3df& translation() const { return _translation; }
135 
136  inline AimsData<float>& rotation() { return _rotation; }
137  inline const AimsData<float>& rotation() const { return _rotation; }
138 
139  virtual bool isIdentity() const;
140  virtual void setToIdentity() ;
141 
142  // AffineTransformation3d algebraic operation
144  virtual void scale( const Point3df& sizeFrom, const Point3df& sizeTo );
146  bool isDirect() const;
147 
148  //Initialisation
149  void setTranslation(Point3df trans);
150  virtual void setRotationAffine( float rx, float ry, float rz,
151  const Point3df &cg = Point3df( 0.0 ) );
152  //virtual void setRotationVectorial( const Point3df& v1, const Point3df& v2 );
153 
155  std::vector<float> toVector() const;
156 
157  static AimsData<float> rotationaroundx(float rx) ;
158  static AimsData<float> rotationaroundy(float ry) ;
159  static AimsData<float> rotationaroundz(float rz) ;
160 
161 
162 protected:
163  virtual Point3dd transformDouble( double x, double y, double z ) const;
164  virtual Point3df transformFloat( float x, float y, float z ) const;
165 
166  virtual Point3dd transformVectorDouble( double x, double y, double z ) const;
167  virtual Point3df transformVectorFloat( float x, float y, float z ) const;
168 
169 
171  // _rotation contient pour le moment la matrice affine en fait!!
174 };
175 
176  // Compose AffineTransformation3d
178  operator * ( const AffineTransformation3d& affineTransformation3d1,
179  const AffineTransformation3d& affineTransformation3d2 );
180 
181 }
182 
183 
184 
185 
186 #ifndef DOXYGEN_HIDE_INTERNAL_CLASSES
187 
188 namespace carto
189 {
190 
191  template <> class DataTypeCode< aims::AffineTransformation3d >
192  {
193  public:
194  static std::string objectType()
195  { return "AffineTransformation3d"; }
196  static std::string dataType()
197  { return "VOID"; }
198  static std::string name()
199  {
200  return "AffineTransformation3d";
201  }
202  };
203 
204 }
205 
206 #endif // DOXYGEN_HIDE_INTERNAL_CLASSES
207 
208 #endif
void setHeader(aims::PythonHeader *ph)
virtual AffineTransformation3d operator-() const
const Point3df & translation() const
virtual void scale(const Point3df &sizeFrom, const Point3df &sizeTo)
Attributed python-like header, stores all needed information about an object, currently used for volu...
Definition: pheader.h:51
AffineTransformation3d & operator*=(const AffineTransformation3d &trans)
static AimsData< float > rotationaroundy(float ry)
static AimsData< float > rotationaroundx(float rx)
virtual bool isIdentity() const
virtual bool operator==(const AffineTransformation3d &)
bool isDirect() const
true if the transformation is direct, false if it changes orientation
virtual Point3dd transformVectorDouble(double x, double y, double z) const
virtual Point3df transformFloat(float x, float y, float z) const
virtual Point3df transformVectorFloat(float x, float y, float z) const
AimsVector< float, 3 > Point3df
Definition: vector.h:237
AffineTransformation3d()
Create an identity transformation.
virtual AffineTransformation3d & operator=(const AffineTransformation3d &other)
const AimsData< float > & rotation() const
void setTranslation(Point3df trans)
AIMSDATA_API GisWriter< T > & operator<<(GisWriter< T > &writer, const AimsData< T > &thing)
Definition: gisW.h:80
static AimsData< float > rotationaroundz(float rz)
virtual void setRotationAffine(float rx, float ry, float rz, const Point3df &cg=Point3df(0.0))
void transformBoundingBox(const AffineTransformation3d &AffineTransformation3d, const Point3df &pmin1, const Point3df &pmax1, Point3df &pmin2, Point3df &pmax2)
std::vector< float > toVector() const
transform AffineTransformation3d to a vector (useful for conversions and IO)
const aims::PythonHeader * header() const
virtual Point3dd transformDouble(double x, double y, double z) const
AffineTransformation3d inverse() const
Affine 3D transformation.
Quaternion operator*(const Quaternion &a, const Quaternion &b)