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. | |
Rotation (const Vector3 &axis, MLdouble angle) | |
Generates a rotation from axis and angle, the angle is given in radians. | |
Rotation (const Vector3 &fromVec, const Vector3 &toVec) | |
Generates a rotation from fromVec to toVec. | |
Rotation (const Matrix4 &m) | |
Generates a rotation from rotation matrix (result is invalid, if the matrix is not a rotation matrix). | |
Rotation (const Rotation &) | |
Copy constructor. | |
Rotation (MLdouble x, MLdouble y, MLdouble z, MLdouble w) | |
Constructs a rotation from quaternion parameters x y z w. | |
Matrix4 | getMatrix () const |
Converts the rotation to a rotation matrix and returns the matrix. | |
void | getRotation (Vector3 &axis, MLdouble &angle) const |
Converts the rotation to an axis axis and and angle angle (in radians). | |
void | setRotation (const Vector3 &axis, MLdouble angle) |
Builds a rotation from an axis axis and an angle angle (in radians). | |
Rotation | multiply (const Rotation &rotation) const |
Multiplies (concatenates) this rotation with rotation and returns the new rotation. | |
Vector3 | rotate (const Vector3 &vec) const |
Rotates the given vector and returns the result vector. | |
Rotation & | conjugate () |
Negates the rotation. | |
Rotation & | operator*= (const Rotation &rotation) |
Multiplies two rotations with each other (see multiply). | |
Rotation & | operator= (const Rotation &rotation) |
Assignment operator. | |
const Vector3 & | getVector () const |
Returns the vector part (x/y/z). | |
MLdouble | getScalar () const |
Returns the scalar part (w). | |
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. | |
static Rotation | slerp (const Rotation &rot1, const Rotation &rot2, MLdouble t) |
Spherical linear interpolation at t between rotation rot1 and rot2. | |
Protected Attributes | |
Vector3 | _vector |
The x,y,z part of the quaternion. | |
MLdouble | _scalar |
The w part of the quaternion. | |
Friends | |
ML_LINEAR_ALGEBRA_EXPORT friend Rotation | operator* (const Rotation &a, const Rotation &b) |
Multiplies two rotations with each other (see multiply). | |
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. For technical details, see: http://skal.planet-d.net/demo/matrixfaq.htm#Q47 The implementation of this class is based on the code examples in the FAQ.
Quaternions extend the concept of rotation in three dimensions to rotation in four dimensions. This avoids the problem of "gimbal-lock" and allows for the implementation of 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 39 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 rotation matrix (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 normalized 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 100 of file mlRotation.h.
|
inline |
Returns the vector part (x/y/z).
Definition at line 98 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 rotation 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 107 of file mlRotation.h.
|
protected |
The x,y,z part of the quaternion.
Definition at line 104 of file mlRotation.h.