Ocular Engine
Ocular::Math::Quaternion Class Reference

Public Member Functions

 Quaternion (float w, float x, float y, float z)
 
 Quaternion (float angle, Vector3< float > const &axis)
 
 Quaternion (Euler const &euler)
 
 Quaternion (Vector3< float > const &euler)
 
 Quaternion (Matrix3x3 const &matrix)
 
 Quaternion (Matrix4x4 const &matrix)
 
 Quaternion (Quaternion_Internal const &data)
 
 Quaternion (Quaternion const &other)
 
Quaternionoperator= (Quaternion const &rhs)
 
Quaternionoperator+= (Quaternion const &rhs)
 
Quaternionoperator*= (Quaternion const &rhs)
 
Quaternionoperator*= (float rhs)
 
Quaternionoperator/= (float rhs)
 
float & w ()
 
float & x ()
 
float & y ()
 
float & z ()
 
float dot (Quaternion const &rhs)
 
void inverse ()
 
Quaternion getInverse () const
 
Quaternion getConjugate () const
 
void normalize ()
 
Quaternion getNormalized () const
 
float getLength () const
 
float getYaw () const
 
float getPitch () const
 
float getRoll () const
 
float getAngle () const
 
Vector3< float > getAxis () const
 
Quaternion cross (Quaternion const &rhs) const
 
Quaternion_InternalgetInternal () const
 

Static Public Member Functions

static Quaternion CreateLookAtRotation (Vector3< float > const &from, Vector3< float > const &to, Vector3< float > const &up)
 
static Quaternion Rotate (Quaternion const &source, float angle, Vector3< float > const &axis)
 
static Quaternion Mix (Quaternion const &a, Quaternion const &b, float f)
 
static Quaternion Lerp (Quaternion const &a, Quaternion const &b, float f)
 
static Quaternion Slerp (Quaternion const &a, Quaternion const &b, float f)
 
static Quaternion Bilerp (Quaternion const &q00, Quaternion const &q10, Quaternion const &q01, Quaternion const &q11, float x, float y)
 

Protected Attributes

Quaternion_Internalm_Internal
 

Constructor & Destructor Documentation

Ocular::Math::Quaternion::Quaternion ( float  angle,
Vector3< float > const &  axis 
)
Parameters
[in]angleAngle to rotate in degrees
[in]axisAxis to rotate around

Member Function Documentation

Quaternion Ocular::Math::Quaternion::Bilerp ( Quaternion const &  q00,
Quaternion const &  q10,
Quaternion const &  q01,
Quaternion const &  q11,
float  x,
float  y 
)
static

Performs bilinear quaternion interpolation and returns the result quaternion.

Parameters
[in]q00"Lower-left" starting point for interpolation (x == 0.0 && y == 0.0)
[in]q10"Lower-right" ending point for interpolation (x == 1.0)
[in]q01"Upper-left" ending point for interpolation (y == 1.0)
[in]q11"Upper-right" ending point for interpolation (x == 1.0 && y == 1.0)
Returns
The resulting Quaternion (not normalized).
Quaternion Ocular::Math::Quaternion::CreateLookAtRotation ( Vector3< float > const &  from,
Vector3< float > const &  to,
Vector3< float > const &  up 
)
static

Creates a LookAt Quaternion rotation.

Note
The result may need to be reversed depending on end use-case (see getConjugate)
Parameters
[in]fromPoint in space to be looking from (aka eye point)
[in]toPoint in spaceto be looking towards
[in]upThe up vector. In most cases, this is the World up vector (Matrix3f::Up())
Quaternion Ocular::Math::Quaternion::getConjugate ( ) const
Returns
The conjugate of the current Quaternion
Quaternion_Internal * Ocular::Math::Quaternion::getInternal ( ) const

For internal use only. Only modify this pointer if you want your application to crash.

Quaternion Ocular::Math::Quaternion::getInverse ( ) const
Returns
The inverse of the current Quaternion (preserves the current Quaternion)
Quaternion Ocular::Math::Quaternion::getNormalized ( ) const
Returns
The normalized form of the current Quaternion (preserves the current Quaternion)
void Ocular::Math::Quaternion::inverse ( )

Inverts the current Quaternion

Quaternion Ocular::Math::Quaternion::Lerp ( Quaternion const &  a,
Quaternion const &  b,
float  f 
)
static

Performs linear quaternion interpolation and returns the resulting quaternion.

Parameters
[in]aThe starting Quaternion (result == a when t == 0.0).
[in]bThe ending Quaternion (result == b when t == 1.0).
[in]fFractional value [0.0, 1.0]
Returns
The resulting Quaternion (not normalized).
void Ocular::Math::Quaternion::normalize ( )

Normalizes the current Quaternion

Quaternion Ocular::Math::Quaternion::Slerp ( Quaternion const &  a,
Quaternion const &  b,
float  f 
)
static

Performs spherical interpolation and returns the resulting quaternion.

Parameters
[in]aThe starting Quaternion (result == a when t == 0.0)
[in]bThe ending Quaternion (result == b when t == 1.0)
[in]fFractional value [0.0, 1.0]
Returns
The resulting Quaternion (not normalized).

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