ML Reference
ml::Rotation Class Reference

Class to handle Rotations (internally the rotation is stored as a quaternion) More...

#include <mlRotation.h>

List of all members.

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.
Rotationconjugate ()
 Negates the rotation.
Rotationoperator*= (const Rotation &rotation)
 Multiply two rotations with each other (see multiply)
Rotationoperator= (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)

Detailed Description

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.


Constructor & Destructor Documentation

ml::Rotation::Rotation ( )

Rotation initialized to identity rotation.

ml::Rotation::Rotation ( const Vector3 axis,
MLdouble  angle 
)

Generate from axis and angle, the angle is given in radian.

ml::Rotation::Rotation ( const Vector3 fromVec,
const Vector3 toVec 
)

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.

ml::Rotation::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)


Member Function Documentation

Rotation& ml::Rotation::conjugate ( )

Negates the rotation.

Matrix4 ml::Rotation::getMatrix ( ) const

Convert the Rotation to a Rotation Matrix.

void ml::Rotation::getRotation ( Vector3 axis,
MLdouble angle 
) const

Convert the Rotation to an axis axis and and angle angle (in radian).

Rotation ml::Rotation::multiply ( const Rotation rotation) const

Multiplies (concatenates) this rotation with rotation and returns the new rotation.

Rotation& ml::Rotation::operator*= ( const Rotation rotation)

Multiply two rotations with each other (see multiply)

Rotation& ml::Rotation::operator= ( const Rotation rotation)

Assignment operator.

Vector3 ml::Rotation::rotate ( const Vector3 vec) const

Rotate the given vector, return the result vector.

void ml::Rotation::setRotation ( const Vector3 axis,
MLdouble  angle 
)

Build a rotation from and axis axis and an angle angle (in radian).

static Matrix4 ml::Rotation::slerp ( const Matrix4 m1,
const Matrix4 m2,
MLdouble  t 
) [static]

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


Friends And Related Function Documentation

ML_LINEAR_ALGEBRA_EXPORT friend Rotation operator* ( const Rotation a,
const Rotation b 
) [friend]

Multiply two rotations with each other (see multiply)


Member Data Documentation

The w part of the quaternion.

Definition at line 96 of file mlRotation.h.

The x,y,z part of the quaternion.

Definition at line 93 of file mlRotation.h.


The documentation for this class was generated from the following file: