ML Reference
|
Class to handle Rotations (internally, the rotation is stored as a unit quaternion) More...
#include <mlRotation.h>
Public Member Functions | |
Rotation () | |
Initializes this rotation to the identity rotation. More... | |
Rotation (const Vector3 &axis, MLdouble angle) | |
Generates a rotation from axis and angle ; the angle is given in radians. More... | |
Rotation (const Vector3 &fromVec, const Vector3 &toVec) | |
Generates a rotation from fromVec to toVec . More... | |
Rotation (const Matrix4 &m) | |
Generates a rotation from a rotation matrix. The result is invalid if the matrix is not a rotation matrix. More... | |
Rotation (const Rotation &) | |
Copy constructor. More... | |
Rotation (MLdouble x, MLdouble y, MLdouble z, MLdouble w) | |
Constructs a rotation from quaternion parameters x y z w. More... | |
Matrix4 | getMatrix () const |
Converts the rotation to a rotation matrix and returns the matrix. More... | |
void | getRotation (Vector3 &axis, MLdouble &angle) const |
Converts the rotation to an axis axis and and angle angle (in radians). More... | |
void | setRotation (const Vector3 &axis, MLdouble angle) |
Builds a rotation from an axis axis and an angle angle (in radians). More... | |
Rotation | multiply (const Rotation &rotation) const |
Multiplies (concatenates) this rotation with rotation and returns the new rotation. More... | |
Vector3 | rotate (const Vector3 &vec) const |
Rotates the given vector and returns the result vector. More... | |
Rotation & | conjugate () |
Negates the rotation. More... | |
Rotation & | operator*= (const Rotation &rotation) |
Multiplies two rotations with each other (see multiply). More... | |
Rotation & | operator= (const Rotation &rotation) |
Assignment operator. More... | |
const Vector3 & | getVector () const |
Returns the vector part (x/y/z). More... | |
MLdouble | getScalar () const |
Returns the scalar part (w). More... | |
Static Public Member Functions | |
static Matrix4 | slerp (const Matrix4 &m1, const Matrix4 &m2, MLdouble t) |
Spherical linear interpolation at t between matrices m1 and [ m2. More... | |
static Rotation | slerp (const Rotation &rot1, const Rotation &rot2, MLdouble t) |
Spherical linear interpolation at t between rotations rot1 and rot2 . More... | |
Protected Attributes | |
Vector3 | _vector |
The x,y,z part of the quaternion. More... | |
MLdouble | _scalar |
The w part of the quaternion. More... | |
Friends | |
ML_LINEAR_ALGEBRA_EXPORT friend Rotation | operator* (const Rotation &a, const Rotation &b) |
Multiplies two rotations with each other (see multiply). More... | |
Class to handle Rotations (internally, the rotation is stored as a unit quaternion)
See "Advanced Animation and Rendering Techniques", Watt, Addison+Wesley, page 360ff for an introduction on quaternions
Quaternions extend the concept of rotation in three dimensions to rotation in four dimensions. This avoids the problem of a 'gimbal-lock' and allows for the implementation of a smooth and continuous rotation. In effect, they may be considered to add an additional rotation angle to spherical coordinates such as Longitude, Latitude, and Rotation angles. A Quaternion is defined using four floating point values |x y z w|. These are calculated from the combination of the three coordinates of the rotation axis and the rotation angle.
Definition at line 37 of file mlRotation.h.
ml::Rotation::Rotation | ( | ) |
Initializes this rotation to the identity rotation.
Generates a rotation from axis
and angle
; the angle is given in radians.
Generates a rotation from fromVec
to toVec
.
ml::Rotation::Rotation | ( | const Matrix4 & | m | ) |
Generates a rotation from a rotation matrix. The result is invalid if the matrix is not a rotation matrix.
ml::Rotation::Rotation | ( | const Rotation & | ) |
Copy constructor.
Constructs a rotation from quaternion parameters x y z w.
These parameters are not axis and angle; read more on quaternions to use this constructor! It accepts any quaternion and normalizes it to a unit quaternion.
Rotation& ml::Rotation::conjugate | ( | ) |
Negates the rotation.
Matrix4 ml::Rotation::getMatrix | ( | ) | const |
Converts the rotation to a rotation matrix and returns the matrix.
Converts the rotation to an axis axis
and and angle angle
(in radians).
|
inline |
Returns the scalar part (w).
Definition at line 99 of file mlRotation.h.
|
inline |
Returns the vector part (x/y/z).
Definition at line 96 of file mlRotation.h.
Multiplies (concatenates) this rotation with rotation
and returns the new rotation.
Multiplies two rotations with each other (see multiply).
Rotates the given vector
and returns the result vector.
Builds a rotation from an axis axis
and an angle angle
(in radians).
Spherical linear interpolation at t
between matrices m1
and [ m2.
Returns an interpolated rotation matrix.
|
static |
Spherical linear interpolation at t
between rotations rot1
and rot2
.
Returns an interpolated rotation.
|
friend |
Multiplies two rotations with each other (see multiply).
|
protected |
The w part of the quaternion.
Definition at line 106 of file mlRotation.h.
|
protected |
The x,y,z part of the quaternion.
Definition at line 103 of file mlRotation.h.