ML Reference
|
Class to handle Rotations (internally the rotation is stored as a quaternion) More...
#include <mlRotation.h>
Public Member Functions | |
Rotation () | |
Rotation initialized to identity rotation. | |
Rotation (const Vector3 &axis, MLdouble angle) | |
Generate from axis and angle, the angle is given in radian. | |
Rotation (const Vector3 &fromVec, const Vector3 &toVec) | |
Generate rotation from fromVec to toVec. | |
Rotation (const Matrix4 &m) | |
Generate 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) | |
Construct rotation from quaternion parameters x y z w (these parameters are NOT axis and angle, read more on quaternions to use this constructor) | |
Matrix4 | getMatrix () const |
Convert the Rotation to a Rotation Matrix. | |
void | getRotation (Vector3 &axis, MLdouble &angle) const |
Convert the Rotation to an axis axis and and angle angle (in radian). | |
void | setRotation (const Vector3 &axis, MLdouble angle) |
Build a rotation from and axis axis and an angle angle (in radian). | |
Rotation | multiply (const Rotation &rotation) const |
Multiplies (concatenates) this rotation with rotation and returns the new rotation. | |
Vector3 | rotate (const Vector3 &vec) const |
Rotate the given vector, return the result vector. | |
Rotation & | conjugate () |
Negates the rotation. | |
Rotation & | operator*= (const Rotation &rotation) |
Multiply two rotations with each other (see multiply) | |
Rotation & | operator= (const Rotation &rotation) |
Assignment operator. | |
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) |
Multiply two rotations with each other (see multiply) |
Class to handle Rotations (internally the rotation is stored as a 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 34 of file mlRotation.h.
ml::Rotation::Rotation | ( | ) |
Rotation initialized to identity rotation.
Generate from axis and angle, the angle is given in radian.
Generate rotation from fromVec to toVec.
ml::Rotation::Rotation | ( | const Matrix4 & | m | ) |
Generate rotation from rotation matrix (result is invalid, if the matrix is not a rotation matrix)
ml::Rotation::Rotation | ( | const Rotation & | ) |
Copy constructor.
Construct rotation from quaternion parameters x y z w (these parameters are NOT axis and angle, read more on quaternions to use this constructor)
Rotation& ml::Rotation::conjugate | ( | ) |
Negates the rotation.
Convert the Rotation to an axis axis and and angle angle (in radian).
Multiplies (concatenates) this rotation with rotation and returns the new rotation.
Multiply two rotations with each other (see multiply)
Rotate the given vector, return the result vector.
Build a rotation from and axis axis and an angle angle (in radian).
spherical linear interpolation at t between matrices m1 and m2.
returns an interpolated rotation matrix
static Rotation ml::Rotation::slerp | ( | const Rotation & | rot1, |
const Rotation & | rot2, | ||
MLdouble | t | ||
) | [static] |
spherical linear interpolation at t between rotation rot1 and rot2.
returns an interpolated rotation
ML_LINEAR_ALGEBRA_EXPORT friend Rotation operator* | ( | const Rotation & | a, |
const Rotation & | b | ||
) | [friend] |
Multiply two rotations with each other (see multiply)
MLdouble ml::Rotation::_scalar [protected] |
The w part of the quaternion.
Definition at line 96 of file mlRotation.h.
Vector3 ml::Rotation::_vector [protected] |
The x,y,z part of the quaternion.
Definition at line 93 of file mlRotation.h.