A.I.M.S


transformation.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 #ifndef AIMS_TRANSFORMATION_TRANSFORMATION_H
35 #define AIMS_TRANSFORMATION_TRANSFORMATION_H
36 
37 #include <aims/vector/vector.h>
38 #include <cartobase/smart/rcptr.h>
39 
40 namespace aims
41 {
42 
43  class Transformation : public virtual carto::RCObject
44  {
45  public:
46  virtual ~Transformation();
47 
48  virtual bool isIdentity() const;
49  virtual void setToIdentity();
50 
51  protected:
53  };
54 
55 
57  {
58  public:
59  virtual ~Transformation3d();
60 
61  Point3dd transform( double x, double y, double z ) const;
62  Point3dd transform( const Point3dd & pos ) const;
63  Point3df transform( const Point3df & dir ) const;
64  Point3df transform( float x, float y, float z ) const;
65  Point3d transform( const Point3d & p ) const;
66  Point3dd transformVector( const Point3dd & vec ) const;
67  Point3df transformVector( const Point3df & dir ) const;
68  Point3dd transformVector( double x, double y, double z ) const;
69  Point3df transformVector( float x, float y, float z ) const;
70  Point3dd transformNormal( const Point3dd & dir ) const;
71  Point3df transformNormal( const Point3df & dir ) const;
72  Point3dd transformNormal( double x, double y, double z ) const;
73  Point3df transformNormal( float x, float y, float z ) const;
74  Point3dd transformUnitNormal( const Point3dd & dir ) const;
75  Point3df transformUnitNormal( const Point3df & dir ) const;
76  Point3dd transformUnitNormal( double x, double y, double z ) const;
77  Point3df transformUnitNormal( float x, float y, float z ) const;
78 
79  protected:
81 
82  virtual Point3dd transformDouble( double x, double y, double z ) const = 0;
83  virtual Point3dd transformPoint3dd( const Point3dd & pos ) const;
84  virtual Point3df transformPoint3df( const Point3df & dir ) const;
85  virtual Point3d transformPoint3d( const Point3d & p ) const;
86  virtual Point3df transformFloat( float x, float y, float z ) const;
87  virtual Point3dd transformVectorPoint3dd( const Point3dd & vec ) const;
88  virtual Point3df transformVectorPoint3df( const Point3df & dir ) const;
89  virtual Point3dd transformVectorDouble( double x, double y,
90  double z ) const;
91  virtual Point3df transformVectorFloat( float x, float y, float z ) const;
92  virtual Point3dd transformNormalPoint3dd( const Point3dd & dir ) const;
93  virtual Point3df transformNormalPoint3df( const Point3df & dir ) const;
94  virtual Point3dd transformNormalDouble( double x, double y,
95  double z ) const;
96  virtual Point3df transformNormalFloat( float x, float y, float z ) const;
97  };
98 
99 
100  // --
101 
102  inline Point3dd
103  Transformation3d::transform( double x, double y, double z ) const
104  {
105  return transformDouble( x, y, z );
106  }
107 
108 
109  inline Point3df
110  Transformation3d::transform( float x, float y, float z ) const
111  {
112  return transformFloat( x, y, z );
113  }
114 
115 
116  inline Point3df Transformation3d::transform( const Point3df & pos ) const
117  {
118  return transformPoint3df( pos );
119  }
120 
121 
122  inline Point3dd
124  {
125  return transformPoint3dd( pos );
126  }
127 
128 
129  inline Point3d
131  {
132  return transformPoint3d( pos );
133  }
134 
135 
136  inline Point3dd
137  Transformation3d::transformVector( double x, double y, double z ) const
138  {
139  return transformVectorDouble( x, y, z );
140  }
141 
142 
143  inline Point3df
144  Transformation3d::transformVector( float x, float y, float z ) const
145  {
146  return transformVectorFloat( x, y, z );
147  }
148 
149 
150  inline Point3df
152  {
153  return transformVectorPoint3df( pos );
154  }
155 
156 
157  inline Point3dd
159  {
160  return transformVectorPoint3dd( pos );
161  }
162 
163 
164  inline Point3dd
165  Transformation3d::transformNormal( double x, double y, double z ) const
166  {
167  return transformNormalDouble( x, y, z );
168  }
169 
170 
171  inline Point3df
172  Transformation3d::transformNormal( float x, float y, float z ) const
173  {
174  return transformNormalFloat( x, y, z );
175  }
176 
177 
178  inline Point3df
180  {
181  return transformNormalPoint3df( pos );
182  }
183 
184 
185  inline Point3dd
187  {
188  return transformNormalPoint3dd( pos );
189  }
190 
191 
192  inline Point3df
194  {
195  Point3dd transformed = transform( (double) pos[0], (double) pos[1],
196  (double) pos[2] );
197  return Point3df( (float) transformed[0], (float) transformed[1],
198  (float) transformed[2] );
199  }
200 
201 
202  inline Point3dd
204  {
205  return transform( pos[0], pos[1], pos[2] );
206  }
207 
208 
209  inline Point3df
210  Transformation3d::transformFloat( float x, float y, float z ) const
211  {
212  Point3dd transformed = transform( (double) x, (double) y, (double) z );
213  return Point3df( (float) transformed[0], (float) transformed[1],
214  (float) transformed[2] );
215  }
216 
217 
218  inline Point3df
220  {
221  Point3dd transformed = transformVector( (double) pos[0], (double) pos[1],
222  (double) pos[2] );
223  return Point3df( (float) transformed[0], (float) transformed[1],
224  (float) transformed[2] );
225  }
226 
227 
228  inline Point3dd
230  {
231  return transformVector( pos[0], pos[1], pos[2] );
232  }
233 
234 
235  inline Point3df
236  Transformation3d::transformVectorFloat( float x, float y, float z ) const
237  {
238  Point3dd transformed = transformVector( (double) x, (double) y,
239  (double) z );
240  return Point3df( (float) transformed[0], (float) transformed[1],
241  (float) transformed[2] );
242  }
243 
244 
245  inline Point3df
247  {
248  Point3dd transformed = transformNormal( (double) pos[0], (double) pos[1],
249  (double) pos[2] );
250  return Point3df( (float) transformed[0], (float) transformed[1],
251  (float) transformed[2] );
252  }
253 
254 
255  inline Point3dd
257  {
258  return transformNormal( pos[0], pos[1], pos[2] );
259  }
260 
261 
262  inline Point3df
263  Transformation3d::transformNormalFloat( float x, float y, float z ) const
264  {
265  Point3dd transformed = transformNormal( (double) x, (double) y,
266  (double) z );
267  return Point3df( (float) transformed[0], (float) transformed[1],
268  (float) transformed[2] );
269  }
270 
271 
272  inline Point3dd
273  Transformation3d::transformUnitNormal( double x, double y, double z ) const
274  {
275  return transformNormal( x, y, z ).normalize();
276  }
277 
278 
279  inline Point3df
281  {
282  Point3dd transformed
283  = transformUnitNormal( (double) pos[0], (double) pos[1],
284  (double) pos[2] );
285  return Point3df( (float) transformed[0], (float) transformed[1],
286  (float) transformed[2] );
287  }
288 
289 
290  inline Point3dd
292  {
293  return transformUnitNormal( pos[0], pos[1], pos[2] );
294  }
295 
296 
297  inline Point3df
298  Transformation3d::transformUnitNormal( float x, float y, float z ) const
299  {
300  Point3dd transformed = transformUnitNormal( (double) x, (double) y,
301  (double) z );
302  return Point3df( (float) transformed[0], (float) transformed[1],
303  (float) transformed[2] );
304  }
305 
306 
308  {
309  Point3dd transformed = transform( (double) p[0], (double) p[1],
310  (double) p[2] );
311  return Point3d( (int16_t) rint( transformed[0] ),
312  (int16_t) rint( transformed[1] ),
313  (int16_t) rint( transformed[2] ) );
314  }
315 
316 }
317 
318 #endif
319 
virtual Point3dd transformNormalDouble(double x, double y, double z) const
virtual Point3d transformPoint3d(const Point3d &p) const
Point3dd transformNormal(const Point3dd &dir) const
virtual Point3dd transformPoint3dd(const Point3dd &pos) const
virtual Point3dd transformNormalPoint3dd(const Point3dd &dir) const
Point3dd transformUnitNormal(const Point3dd &dir) const
The template class to implement basic vectors.
Definition: vector.h:48
virtual Point3df transformFloat(float x, float y, float z) const
virtual ~Transformation()
AimsVector< T, D > & normalize()
Definition: vector.h:597
Point3dd transformVector(const Point3dd &vec) const
virtual Point3df transformVectorPoint3df(const Point3df &dir) const
virtual Point3df transformPoint3df(const Point3df &dir) const
virtual Point3df transformVectorFloat(float x, float y, float z) const
virtual Point3dd transformVectorPoint3dd(const Point3dd &vec) const
AimsVector< float, 3 > Point3df
Definition: vector.h:237
virtual void setToIdentity()
Point3dd transform(double x, double y, double z) const
virtual Point3df transformNormalFloat(float x, float y, float z) const
virtual bool isIdentity() const
AimsVector< int16_t, 3 > Point3d
Definition: vector.h:212
virtual Point3dd transformDouble(double x, double y, double z) const =0
virtual Point3df transformNormalPoint3df(const Point3df &dir) const
virtual Point3dd transformVectorDouble(double x, double y, double z) const