CrystalSpace

Public API Reference

csQuaternion Class Reference
[Geometry utilities]

Class for a quaternion. More...

#include <csgeom/quaternion.h>

List of all members.

Public Member Functions

void Conjugate ()
 Set this quaternion to its own conjugate.
 csQuaternion (const csQuaternion &q)
 Copy-constructor.
 csQuaternion (const csVector3 &v, float w)
 Construct from a vector and given w value.
 csQuaternion (float x, float y, float z, float w)
 Initialize with given values. Does not normalize.
 csQuaternion ()
 Initialize with identity.
float Dot (const csQuaternion &q) const
 Return euclidian inner-product (dot).
csQuaternion Exp () const
 Get quaternion exp.
void GetAxisAngle (csVector3 &axis, float &angle) const
 Get a quaternion as axis-angle representation.
csQuaternion GetConjugate () const
 Get the conjugate quaternion.
csVector3 GetEulerAngles () const
 Get quaternion as three Euler angles X, Y, Z, expressed in radians.
csMatrix3 GetMatrix () const
 Get quaternion as a 3x3 rotation matrix.
csQuaternion Log () const
 Get quaternion log.
csQuaternion NLerp (const csQuaternion &q2, float t) const
 Interpolate this quaternion with another using normalized linear interpolation (nlerp) using given interpolation factor.
float Norm () const
 Get the norm of this quaternion.
csQuaternionoperator *= (const csQuaternion &q)
 Multiply this quaternion by another.
csQuaternionoperator+= (const csQuaternion &q)
 Add quaternion to this one.
csQuaternionoperator-= (const csQuaternion &q)
 Subtract quaternion from this one.
csVector3 Rotate (const csVector3 &src) const
 Rotate vector by quaternion.
void Set (float x, float y, float z, float w)
 Set the components.
void SetAxisAngle (const csVector3 &axis, float angle)
 Set a quaternion using axis-angle representation.
void SetEulerAngles (const csVector3 &angles)
 Set quaternion using Euler angles X, Y, Z, expressed in radians.
void SetIdentity ()
 Set quaternion to identity rotation.
void SetMatrix (const csMatrix3 &matrix)
 Set quaternion using 3x3 rotation matrix.
csQuaternion SLerp (const csQuaternion &q2, float t) const
 Interpolate this quaternion with another using spherical linear interpolation (slerp) using given interpolation factor.
csQuaternion Squad (const csQuaternion &t1, const csQuaternion &t2, const csQuaternion &q, float t) const
 Interpolate this quaternion with another (q) using cubic linear interpolation (squad) using given interpolation factor (t) and tangents (t1 and t2).
float SquaredNorm () const
 Get the squared norm of this quaternion (equals dot with itself).
csQuaternion Unit () const
 Return a unit-lenght version of this quaternion (also called sgn) Attempting to normalize a zero-length quaternion will result in a divide by zero error.

Public Attributes

csVector3 v
float w

Friends

csQuaternion operator * (float f, const csQuaternion q)
 Multiply by scalar.
csQuaternion operator * (const csQuaternion q, float f)
 Multiply by scalar.
csQuaternion operator * (const csQuaternion &q1, const csQuaternion &q2)
 Multiply two quaternions, Grassmann product.
csQuaternion operator+ (const csQuaternion &q1, const csQuaternion &q2)
 Add two quaternions.
csQuaternion operator- (const csQuaternion &q)
 Get the negative quaternion (unary minus).
csQuaternion operator- (const csQuaternion &q1, const csQuaternion &q2)
 Subtract two quaternions.
csQuaternion operator/ (float f, const csQuaternion q)
 Divide by scalar.
csQuaternion operator/ (const csQuaternion q, float f)
 Divide by scalar.


Detailed Description

Class for a quaternion.

A SE3 rotation represented as a normalized quaternion

Definition at line 41 of file quaternion.h.


Constructor & Destructor Documentation

csQuaternion::csQuaternion (  )  [inline]

Initialize with identity.

Definition at line 47 of file quaternion.h.

csQuaternion::csQuaternion ( float  x,
float  y,
float  z,
float  w 
) [inline]

Initialize with given values. Does not normalize.

Definition at line 52 of file quaternion.h.

csQuaternion::csQuaternion ( const csVector3 v,
float  w 
) [inline]

Construct from a vector and given w value.

Definition at line 57 of file quaternion.h.

csQuaternion::csQuaternion ( const csQuaternion q  )  [inline]

Copy-constructor.

Definition at line 62 of file quaternion.h.


Member Function Documentation

void csQuaternion::Conjugate (  )  [inline]

Set this quaternion to its own conjugate.

Definition at line 167 of file quaternion.h.

float csQuaternion::Dot ( const csQuaternion q  )  const [inline]

Return euclidian inner-product (dot).

Definition at line 173 of file quaternion.h.

References v, and w.

csQuaternion csQuaternion::Exp (  )  const

Get quaternion exp.

void csQuaternion::GetAxisAngle ( csVector3 axis,
float &  angle 
) const [inline]

Get a quaternion as axis-angle representation.

Parameters:
axis Rotation axis.
angle Angle to rotate about axis (in radians)

Definition at line 231 of file quaternion.h.

References csVector3::Set(), and csVector3::Unit().

csQuaternion csQuaternion::GetConjugate (  )  const [inline]

Get the conjugate quaternion.

Definition at line 161 of file quaternion.h.

csVector3 csQuaternion::GetEulerAngles (  )  const

Get quaternion as three Euler angles X, Y, Z, expressed in radians.

csMatrix3 csQuaternion::GetMatrix (  )  const

Get quaternion as a 3x3 rotation matrix.

csQuaternion csQuaternion::Log (  )  const

Get quaternion log.

csQuaternion csQuaternion::NLerp ( const csQuaternion q2,
float  t 
) const

Interpolate this quaternion with another using normalized linear interpolation (nlerp) using given interpolation factor.

float csQuaternion::Norm (  )  const [inline]

Get the norm of this quaternion.

Definition at line 185 of file quaternion.h.

References csQsqrt().

csQuaternion& csQuaternion::operator *= ( const csQuaternion q  )  [inline]

Multiply this quaternion by another.

Definition at line 126 of file quaternion.h.

References v, and w.

csQuaternion& csQuaternion::operator+= ( const csQuaternion q  )  [inline]

Add quaternion to this one.

Definition at line 91 of file quaternion.h.

References v, and w.

csQuaternion& csQuaternion::operator-= ( const csQuaternion q  )  [inline]

Subtract quaternion from this one.

Definition at line 105 of file quaternion.h.

References v, and w.

csVector3 csQuaternion::Rotate ( const csVector3 src  )  const [inline]

Rotate vector by quaternion.

Definition at line 203 of file quaternion.h.

References v.

void csQuaternion::Set ( float  x,
float  y,
float  z,
float  w 
) [inline]

Set the components.

Definition at line 69 of file quaternion.h.

Referenced by csShaderVariable::GetValue().

void csQuaternion::SetAxisAngle ( const csVector3 axis,
float  angle 
) [inline]

Set a quaternion using axis-angle representation.

Parameters:
axis Rotation axis. Should be normalized before calling this function.
angle Angle to rotate about axis (in radians)

Definition at line 218 of file quaternion.h.

void csQuaternion::SetEulerAngles ( const csVector3 angles  ) 

Set quaternion using Euler angles X, Y, Z, expressed in radians.

void csQuaternion::SetIdentity (  )  [inline]

Set quaternion to identity rotation.

Definition at line 78 of file quaternion.h.

void csQuaternion::SetMatrix ( const csMatrix3 matrix  ) 

Set quaternion using 3x3 rotation matrix.

csQuaternion csQuaternion::SLerp ( const csQuaternion q2,
float  t 
) const

Interpolate this quaternion with another using spherical linear interpolation (slerp) using given interpolation factor.

csQuaternion csQuaternion::Squad ( const csQuaternion t1,
const csQuaternion t2,
const csQuaternion q,
float  t 
) const

Interpolate this quaternion with another (q) using cubic linear interpolation (squad) using given interpolation factor (t) and tangents (t1 and t2).

float csQuaternion::SquaredNorm (  )  const [inline]

Get the squared norm of this quaternion (equals dot with itself).

Definition at line 179 of file quaternion.h.

csQuaternion csQuaternion::Unit (  )  const [inline]

Return a unit-lenght version of this quaternion (also called sgn) Attempting to normalize a zero-length quaternion will result in a divide by zero error.

This is as it should be... fix the calling code.

Definition at line 195 of file quaternion.h.


Friends And Related Function Documentation

csQuaternion operator * ( float  f,
const csQuaternion  q 
) [friend]

Multiply by scalar.

Definition at line 141 of file quaternion.h.

csQuaternion operator * ( const csQuaternion  q,
float  f 
) [friend]

Multiply by scalar.

Definition at line 135 of file quaternion.h.

csQuaternion operator * ( const csQuaternion q1,
const csQuaternion q2 
) [friend]

Multiply two quaternions, Grassmann product.

Definition at line 118 of file quaternion.h.

csQuaternion operator+ ( const csQuaternion q1,
const csQuaternion q2 
) [friend]

Add two quaternions.

Definition at line 84 of file quaternion.h.

csQuaternion operator- ( const csQuaternion q  )  [friend]

Get the negative quaternion (unary minus).

Definition at line 112 of file quaternion.h.

csQuaternion operator- ( const csQuaternion q1,
const csQuaternion q2 
) [friend]

Subtract two quaternions.

Definition at line 98 of file quaternion.h.

csQuaternion operator/ ( float  f,
const csQuaternion  q 
) [friend]

Divide by scalar.

Definition at line 154 of file quaternion.h.

csQuaternion operator/ ( const csQuaternion  q,
float  f 
) [friend]

Divide by scalar.

Definition at line 147 of file quaternion.h.


The documentation for this class was generated from the following file:
Generated for Crystal Space 1.2.1 by doxygen 1.5.3