aimsdata  4.7.0
Neuroimaging data handling
quaternion.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 #ifndef AIMS_RESAMPLING_QUATERNION_H
36 #define AIMS_RESAMPLING_QUATERNION_H
37 
38 
39 #include <aims/vector/vector.h>
40 #include <aims/data/data.h>
41 
42 namespace aims
43 {
44  class AffineTransformation3d;
45 }
47 
48 namespace aims
49 {
50 
51  class Quaternion
52  {
53  public:
54  friend Quaternion operator * ( const Quaternion &, const Quaternion & );
55 
56  Quaternion();
57  Quaternion( const Point4df & q );
58  Quaternion( const Quaternion & q );
59  Quaternion( float x, float y, float z, float t );
60  ~Quaternion();
61 
62  Quaternion & operator = ( const Quaternion & q );
63  const Point4df & vector() const { return( _vector ); }
64  void setVector( const Point4df & vec );
69  void buildFromMatrix( const float* m );
70  void buildFromMotion( const Motion & m );
72  Point3df transform( float x, float y, float z ) const
73  { return transform( Point3df( x, y, z ) ); }
75  Point3df transform( const Point3df & p ) const;
76  Point3df transformInverse( const Point3df & p ) const;
77  Quaternion & operator *= ( const Quaternion & q );
78  void norm();
79  Quaternion normalized() const;
80  void fromAxis( const Point3df & c, float phi );
81  Quaternion inverse() const;
82  Point3df axis() const;
83  float angle() const;
84 
85  static float dot( const Quaternion & a, const Quaternion & b )
86  { return( dot( a._vector, b._vector ) ); }
87  static float dot( const Point4df & a, const Point4df & b );
88  static Point4df cross( const Point4df & a, const Point4df & b );
89  static Point3df norm( const Point3df & a );
90 
91  protected:
93  };
94 
95 
96  Quaternion operator * ( const Quaternion & a, const Quaternion & b );
97 
98 }
99 
100 
101 #endif
Point3df transformInverse(const Point3df &p) const
Quaternion normalized() const
Quaternion & operator=(const Quaternion &q)
const Point4df & vector() const
Definition: quaternion.h:63
aims::AffineTransformation3d Motion
Definition: quaternion.h:46
Quaternion & operator*=(const Quaternion &q)
friend Quaternion operator*(const Quaternion &, const Quaternion &)
The class for EcatSino data write operation.
Definition: border.h:42
static Point4df cross(const Point4df &a, const Point4df &b)
Point4df _vector
Definition: quaternion.h:92
Point3df axis() const
void fromAxis(const Point3df &c, float phi)
Quaternion inverse() const
Point3df transform(float x, float y, float z) const
Rotates vecotor (x,y,z)
Definition: quaternion.h:72
AimsVector< float, 16 > inverseRotationMatrix() const
static float dot(const Quaternion &a, const Quaternion &b)
Definition: quaternion.h:85
float angle() const
void setVector(const Point4df &vec)
void buildFromMotion(const Motion &m)
AimsVector< float, 16 > rotationMatrix() const
in OpenGL style: in columns
void buildFromMatrix(const float *m)
4x4 matrix in columns (OpenGL-style)
Affine 3D transformation.