MeVisLab Toolbox Reference
mlRotation.h
Go to the documentation of this file.
1 /*************************************************************************************
2 **
3 ** Copyright 2010, MeVis Medical Solutions AG
4 **
5 ** The user may use this file in accordance with the license agreement provided with
6 ** the Software or, alternatively, in accordance with the terms contained in a
7 ** written agreement between the user and MeVis Medical Solutions AG.
8 **
9 ** For further information use the contact form at https://www.mevislab.de/contact
10 **
11 **************************************************************************************/
12 
13 #ifndef ML_ROTATION_H
14 #define ML_ROTATION_H
15 
17 
18 #include "mlLinearAlgebraSystem.h"
19 #include "mlVector3.h"
20 #include "mlMatrix4.h"
21 
22 ML_LA_START_NAMESPACE
23 
25 
40  {
41  public:
44 
46  Rotation (const Vector3& axis, MLdouble angle);
47 
49  Rotation (const Vector3& fromVec, const Vector3& toVec);
50 
52  Rotation (const Matrix4& m);
53 
55  Rotation (const Rotation&);
56 
61 
63  Matrix4 getMatrix () const;
64 
66  void getRotation (Vector3& axis, MLdouble &angle) const;
67 
69  void setRotation (const Vector3& axis, MLdouble angle);
70 
72  Rotation multiply (const Rotation& rotation) const;
73 
75  Vector3 rotate(const Vector3& vec) const;
76 
79 
81  Rotation& operator*=(const Rotation& rotation);
82 
84  Rotation& operator= (const Rotation& rotation);
85 
88 
91  static Matrix4 slerp(const Matrix4& m1, const Matrix4& m2, MLdouble t);
92 
95  static Rotation slerp(const Rotation& rot1, const Rotation& rot2, MLdouble t);
96 
98  const Vector3& getVector() const { return _vector; }
100  MLdouble getScalar() const { return _scalar; }
101 
102  protected:
105 
108 
109  private:
111  void _normalize();
112 
114  static Matrix4 _outer (const Vector3& v);
115 
117  static Matrix4 _generator (const Vector3& v);
118  };
119 
120 ML_LA_END_NAMESPACE
121 
122 
123 #endif // __mlRotation_H
Class to handle Rotations (internally the rotation is stored as a unit quaternion)
Definition: mlRotation.h:40
Rotation & conjugate()
Negates the rotation.
MLdouble getScalar() const
Returns the scalar part (w).
Definition: mlRotation.h:100
Rotation(const Matrix4 &m)
Generates a rotation from rotation matrix (result is invalid, if the matrix is not a rotation matrix)...
Vector3 rotate(const Vector3 &vec) const
Rotates the given vector and returns the result vector.
Rotation(const Rotation &)
Copy constructor.
ML_LINEAR_ALGEBRA_EXPORT friend Rotation operator*(const Rotation &a, const Rotation &b)
Multiplies two rotations with each other (see multiply).
void setRotation(const Vector3 &axis, MLdouble angle)
Builds a rotation from an axis axis and an angle angle (in radians).
Rotation()
Initializes this rotation to the identity rotation.
static Rotation slerp(const Rotation &rot1, const Rotation &rot2, MLdouble t)
Spherical linear interpolation at t between rotation rot1 and rot2.
Rotation multiply(const Rotation &rotation) const
Multiplies (concatenates) this rotation with rotation and returns the new rotation.
Rotation(MLdouble x, MLdouble y, MLdouble z, MLdouble w)
Constructs a rotation from quaternion parameters x y z w.
MLdouble _scalar
The w part of the quaternion.
Definition: mlRotation.h:107
Matrix4 getMatrix() const
Converts the rotation to a rotation matrix and returns the matrix.
Rotation(const Vector3 &axis, MLdouble angle)
Generates a rotation from axis and angle, the angle is given in radians.
const Vector3 & getVector() const
Returns the vector part (x/y/z).
Definition: mlRotation.h:98
Vector3 _vector
The x,y,z part of the quaternion.
Definition: mlRotation.h:104
Rotation & operator*=(const Rotation &rotation)
Multiplies two rotations with each other (see multiply).
Rotation(const Vector3 &fromVec, const Vector3 &toVec)
Generates a rotation from fromVec to toVec.
static Matrix4 slerp(const Matrix4 &m1, const Matrix4 &m2, MLdouble t)
Spherical linear interpolation at t between matrices m1 and m2.
void getRotation(Vector3 &axis, MLdouble &angle) const
Converts the rotation to an axis axis and and angle angle (in radians).
#define ML_LINEAR_ALGEBRA_EXPORT
Defines all system specific settings for all linear algebra classes.
double MLdouble
Definition: mlTypeDefs.h:223