Quaternion Class Reference

#include <Quaternion.h>

Inheritance diagram for Quaternion:

Vec< 4 > List of all members.

Detailed Description

A Quaternion is a Vec4 with the following behavior:

This corresponds to rotation angles in the range -180 < a <= 180 degrees. Quaternions are not required to be in canonical form (e.g., during numerical integration). When appropriate, they are put in canonical form.

Conversion from quaternion to (angle,axis) form is handled here also. (angle,axis) is in canonical form when -180 < angle <= 180 and |axis|=1. However, (angle,axis) is meaningful for any angle and for any axis where |axis| > 0.


Public Member Functions

 Quaternion ()
 Default constructor produces the ZeroRotation quaternion [1 0 0 0] (not NaN - even in debug mode).
 Quaternion (const Quaternion &q)
 Zero-cost copy constructor just copies the source without conversion to canonical form or normalization.
Quaternionoperator= (const Quaternion &q)
 Zero-cost copy assignment just copies the source without conversion to canonical form or normalization.
 Quaternion (Real e0, Real e1, Real e2, Real e3)
 Construct a quaternion and normalize it.
 Quaternion (const Vec4 &q)
 Quaternion (const Rotation &)
 Constructs a canonical quaternion from a rotation matrix (cost is about 60 flops).
void setQuaternionToZeroRotation ()
 The ZeroRotation quaternion is [1 0 0 0].
void setQuaternionToNaN ()
void setQuaternionFromAngleAxis (const Vec4 &av)
 The quaternion that is set by this method has a non-negative first element (canonical form).
void setQuaternionFromAngleAxis (const Real &a, const UnitVec3 &v)
Vec4 convertQuaternionToAngleAxis () const
 Returns [ a vx vy vz ] with (a,v) in canonical form, i.e., -180 < a <= 180 and |v|=1.
const Vec4asVec4 () const
 Zero-cost cast of a Quaternion to a Vec4.
QuaternionnormalizeThis ()
 Normalize an already constructed quaternion.
 Quaternion (const Vec4 &v, bool)
 Use this constructor only if you are *sure* v is normalized to 1.0.


Constructor & Destructor Documentation

Quaternion (  )  [inline]

Default constructor produces the ZeroRotation quaternion [1 0 0 0] (not NaN - even in debug mode).

Quaternion ( const Quaternion q  )  [inline]

Zero-cost copy constructor just copies the source without conversion to canonical form or normalization.

Quaternion ( Real  e0,
Real  e1,
Real  e2,
Real  e3 
) [inline]

Construct a quaternion and normalize it.

Quaternion ( const Vec4 q  )  [inline, explicit]

Quaternion ( const Rotation  )  [explicit]

Constructs a canonical quaternion from a rotation matrix (cost is about 60 flops).

Quaternion ( const Vec4 v,
bool   
) [inline]

Use this constructor only if you are *sure* v is normalized to 1.0.

This zero cost method is faster than the Quaternion(Vec4) constructor which normalizes the Vec4. The second argument forces the compiler to call the fast constructor; it is otherwise ignored. By convention, set the second argument to "true".


Member Function Documentation

const Vec4& asVec4 (  )  const [inline]

Zero-cost cast of a Quaternion to a Vec4.

Vec4 convertQuaternionToAngleAxis (  )  const

Returns [ a vx vy vz ] with (a,v) in canonical form, i.e., -180 < a <= 180 and |v|=1.

Quaternion& normalizeThis (  )  [inline]

Normalize an already constructed quaternion.

If the quaternion is *exactly* zero, set it to [1 0 0 0]. If its magnitude is: 0 < magnitude < epsilon (epsilon is machine tolerance), set it to NaN (treated as an error). Otherwise, normalize the quaternion which costs about 40 flops. The quaternion is NOT put in canonical form.

Quaternion& operator= ( const Quaternion q  )  [inline]

Zero-cost copy assignment just copies the source without conversion to canonical form or normalization.

void setQuaternionFromAngleAxis ( const Real &  a,
const UnitVec3 v 
)

void setQuaternionFromAngleAxis ( const Vec4 av  ) 

The quaternion that is set by this method has a non-negative first element (canonical form).

If the "axis" portion of av is a zero vector, the quaternion is set to all-NaN.

void setQuaternionToNaN (  )  [inline]

void setQuaternionToZeroRotation (  )  [inline]

The ZeroRotation quaternion is [1 0 0 0].

Note: Default constructor is ZeroRotation (unlike Vec4 which start as NaN in Debug mode).


The documentation for this class was generated from the following file:
Generated on Thu Feb 28 01:34:36 2008 for SimTKcommon by  doxygen 1.4.7