# 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 the exponential of this quaternion.
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 the logarithm of this quaternion.
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*= (float f)
Multiply by scalar.
csQuaternionoperator*= (const csQuaternion &q)
Multiply this quaternion by another.
csQuaternionoperator+= (const csQuaternion &q)
csQuaternionoperator-= (const csQuaternion &q)
Subtract quaternion from this one.
csQuaternionoperator/= (float f)
Divide by scalar.
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
x, y and z components of the quaternion
float w
w component of the quaternion

## 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)
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

csDualQuaternion

Definition at line 42 of file quaternion.h.

## Constructor & Destructor Documentation

 csQuaternion::csQuaternion ( ) ` [inline]`

Initialize with identity.

Definition at line 48 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 53 of file quaternion.h.

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

Construct from a vector and given w value.

Definition at line 58 of file quaternion.h.

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

Copy-constructor.

Definition at line 63 of file quaternion.h.

## Member Function Documentation

 void csQuaternion::Conjugate ( ) ` [inline]`

Set this quaternion to its own conjugate.

Definition at line 187 of file quaternion.h.

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

Return euclidian inner-product (dot).

Definition at line 193 of file quaternion.h.

 csQuaternion csQuaternion::Exp ( ) const

Get the exponential of this quaternion.

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

Get a quaternion as axis-angle representation.

Parameters:

Definition at line 251 of file quaternion.h.

 csQuaternion csQuaternion::GetConjugate ( ) const` [inline]`

Get the conjugate quaternion.

Definition at line 181 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 the logarithm of this quaternion.

 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 205 of file quaternion.h.

 csQuaternion& csQuaternion::operator*= ( float f ) ` [inline]`

Multiply by scalar.

Definition at line 148 of file quaternion.h.

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

Multiply this quaternion by another.

Definition at line 127 of file quaternion.h.

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

Definition at line 92 of file quaternion.h.

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

Subtract quaternion from this one.

Definition at line 106 of file quaternion.h.

 csQuaternion& csQuaternion::operator/= ( float f ) ` [inline]`

Divide by scalar.

Definition at line 171 of file quaternion.h.

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

Rotate vector by quaternion.

Definition at line 223 of file quaternion.h.

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

Set the components.

Definition at line 70 of file quaternion.h.

 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 238 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 79 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 199 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 215 of file quaternion.h.

## Friends And Related Function Documentation

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

Multiply by scalar.

Definition at line 142 of file quaternion.h.

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

Multiply by scalar.

Definition at line 136 of file quaternion.h.

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

Multiply two quaternions, Grassmann product.

Definition at line 119 of file quaternion.h.

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

Definition at line 85 of file quaternion.h.

 csQuaternion operator- ( const csQuaternion & q ) ` [friend]`

Get the negative quaternion (unary minus).

Definition at line 113 of file quaternion.h.

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

Subtract two quaternions.

Definition at line 99 of file quaternion.h.

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

Divide by scalar.

Definition at line 164 of file quaternion.h.

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

Divide by scalar.

Definition at line 157 of file quaternion.h.

## Member Data Documentation

x, y and z components of the quaternion

Definition at line 311 of file quaternion.h.

 float csQuaternion::w

w component of the quaternion

Definition at line 314 of file quaternion.h.

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

Generated for Crystal Space 2.0 by doxygen 1.6.1