ML 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
19#include "mlVector3.h"
20#include "mlMatrix4.h"
21
22ML_LA_START_NAMESPACE
23
25
38 {
39 public:
42
44 Rotation (const Vector3& axis, MLdouble angle);
45
47 Rotation (const Vector3& fromVec, const Vector3& toVec);
48
50 Rotation (const Matrix4& m);
51
54
59
62
64 void getRotation (Vector3& axis, MLdouble &angle) const;
65
67 void setRotation (const Vector3& axis, MLdouble angle);
68
70 Rotation multiply (const Rotation& rotation) const;
71
73 Vector3 rotate(const Vector3& vec) const;
74
77
79 Rotation& operator*=(const Rotation& rotation);
80
82 Rotation& operator= (const Rotation& rotation);
83
86
89 static Matrix4 slerp(const Matrix4& m1, const Matrix4& m2, MLdouble t);
90
93 static Rotation slerp(const Rotation& rot1, const Rotation& rot2, MLdouble t);
94
96 const Vector3& getVector() const { return _vector; }
97
99 MLdouble getScalar() const { return _scalar; }
100
101 protected:
104
107
108 private:
110 void _normalize();
111
113 static Matrix4 _outer (const Vector3& v);
114
116 static Matrix4 _generator (const Vector3& v);
117 };
118
119ML_LA_END_NAMESPACE
120
121
122#endif // __mlRotation_H
Class to handle Rotations (internally, the rotation is stored as a unit quaternion)
Definition mlRotation.h:38
MLdouble getScalar() const
Returns the scalar part (w).
Definition mlRotation.h:99
Rotation(const Matrix4 &m)
Generates a rotation from a rotation matrix. The result is invalid if the matrix is not a rotation ma...
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.
Rotation & conjugate()
Negates the rotation.
static Rotation slerp(const Rotation &rot1, const Rotation &rot2, MLdouble t)
Spherical linear interpolation at t between rotations rot1 and rot2.
Rotation multiply(const Rotation &rotation) const
Multiplies (concatenates) this rotation with rotation and returns the new rotation.
Rotation & operator*=(const Rotation &rotation)
Multiplies two rotations with each other (see multiply).
Rotation(MLdouble x, MLdouble y, MLdouble z, MLdouble w)
Constructs a rotation from quaternion parameters x y z w.
const Vector3 & getVector() const
Returns the vector part (x/y/z).
Definition mlRotation.h:96
MLdouble _scalar
The w part of the quaternion.
Definition mlRotation.h:106
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.
Vector3 _vector
The x,y,z part of the quaternion.
Definition mlRotation.h:103
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:217