PixelLightAPI  .
Public Types | Public Member Functions | Public Attributes | Static Public Attributes
PLMath::Quaternion Class Reference

Quaternion. More...

#include <Quaternion.h>

List of all members.

Public Types

enum  Component { W = 0, X = 1, Y = 2, Z = 3 }
 Component. More...

Public Member Functions

 Quaternion ()
 Default constructor setting an identity quaternion.
 Quaternion (float fW, float fX, float fY, float fZ)
 Quaternion (const float fQ[])
 Quaternion (const Quaternion &qQ)
 Quaternion (const Vector3 &vAxis, float fAngle)
PLMATH_API Quaternion (const Matrix3x3 &mRot)
PLMATH_API Quaternion (const Matrix3x4 &mRot)
PLMATH_API Quaternion (const Matrix4x4 &mRot)
 ~Quaternion ()
Quaternion operator+ (const Quaternion &qQ) const
Quaternionoperator+= (const Quaternion &qQ)
Quaternion operator- () const
Quaternion operator- (const Quaternion &qQ) const
Quaternionoperator-= (const Quaternion &qQ)
Quaternion operator* (float f) const
Quaternionoperator*= (float f)
Quaternion operator* (const Quaternion &qQ) const
Quaternionoperator*= (const Quaternion &qQ)
Vector3 operator* (const Vector3 &vV) const
Vector4 operator* (const Vector4 &vV) const
Quaternion operator/ (float f) const
Quaternionoperator/= (float f)
Quaternionoperator= (const Quaternion &qQ)
bool operator== (const Quaternion &qQ) const
bool operator!= (const Quaternion &qQ) const
 operator float * ()
 operator const float * () const
QuaternionSetWXYZ (float fW, float fX, float fY, float fZ)
 Sets the component of the quaternion.
QuaternionSetWXYZ (const float fValues[])
 Sets the component of the quaternion.
PLMATH_API void ToAxisAngle (float &fX, float &fY, float &fZ, float &fAngle) const
 Returns a selected axis and angle from the rotation quaternion.
PLMATH_API QuaternionFromAxisAngle (float fX, float fY, float fZ, float fAngle)
 Sets a rotation quaternion by using a selected axis and angle.
PLMATH_API Vector3 GetXAxis () const
 Returns the x (left) axis.
PLMATH_API Vector3 GetYAxis () const
 Returns the y (up) axis.
PLMATH_API Vector3 GetZAxis () const
 Returns the z (forward) axis.
PLMATH_API void ToRotationMatrix (Matrix3x3 &mRot) const
 Returns the rotation quaternion as 3x3 matrix.
PLMATH_API QuaternionFromRotationMatrix (const Matrix3x3 &mRot)
 Sets a rotation quaternion by using a 3x3 rotation matrix.
PLMATH_API void ToRotationMatrix (Matrix3x4 &mRot) const
 Returns the rotation quaternion as 3x4 matrix.
PLMATH_API QuaternionFromRotationMatrix (const Matrix3x4 &mRot)
 Sets a rotation quaternion by using a 3x4 rotation matrix.
PLMATH_API void ToRotationMatrix (Matrix4x4 &mRot) const
 Returns the rotation quaternion as 4x4 matrix.
PLMATH_API QuaternionFromRotationMatrix (const Matrix4x4 &mRot)
 Sets a rotation quaternion by using a 4x4 rotation matrix.
bool Compare (const Quaternion &qQ, float fEpsilon=Math::Epsilon) const
 Compares two quaternions using an epsilon environment.
float GetLength () const
 Returns the length (also called magnitude) of the quaternion.
float GetSquaredLength () const
 Returns the squared length (norm) of the quaternion.
float DotProduct (const Quaternion &qQ) const
 Returns the dot product of this quaternion and another one.
QuaternionNormalize ()
 Normalizes the quaternion.
Quaternion GetNormalized () const
 Returns a normalized quaternion.
void Conjugate ()
 Conjugates the quaternion.
Quaternion GetConjugated () const
 Returns the conjugated of the quaternion.
void Invert ()
 Inverts the quaternion.
Quaternion GetInverted () const
 Returns the inverted quaternion.
void UnitInvert ()
 Inverts the normalized quaternion.
Quaternion GetUnitInverted () const
 Returns the inverted normalized quaternion.
QuaternionExp ()
 Calculates the exponential of the quaternion.
Quaternion GetExp () const
 Returns the exponential of the quaternion.
QuaternionLog ()
Quaternion GetLog () const
QuaternionPower (float fPower)
 Calculates the power of the quaternion.
Quaternion GetPower (float fPower) const
 Returns the power of the quaternion.
PLMATH_API void Slerp (const Quaternion &qQ1, const Quaternion &qQ2, float fTime)
 Computes spherical linear interpolation between qQ1 and qQ2 with time 0-1.
PLMATH_API PLCore::String ToString () const
 To string.
PLMATH_API bool FromString (const PLCore::String &sString)
 From string.

Public Attributes

union {
   float   fQ [4]
   struct {
      float   w
      float   x
      float   y
      float   z
   } 
}; 
 Some direct quaternion element accesses.

Static Public Attributes

static PLMATH_API const Quaternion Zero
static PLMATH_API const Quaternion Identity

Detailed Description

Quaternion.

Note:
  • Orientation quaternions are unit quaternions

Member Enumeration Documentation

Component.

Enumerator:
W 

W component

X 

X component

Y 

Y component

Z 

Z component


Constructor & Destructor Documentation

Default constructor setting an identity quaternion.

PLMath::Quaternion::Quaternion ( float  fW,
float  fX,
float  fY,
float  fZ 
) [inline]
PLMath::Quaternion::Quaternion ( const float  fQ[]) [inline]
PLMath::Quaternion::Quaternion ( const Quaternion qQ) [inline]
PLMath::Quaternion::Quaternion ( const Vector3 vAxis,
float  fAngle 
) [inline]
PLMATH_API PLMath::Quaternion::Quaternion ( const Matrix3x3 mRot)
PLMATH_API PLMath::Quaternion::Quaternion ( const Matrix3x4 mRot)
PLMATH_API PLMath::Quaternion::Quaternion ( const Matrix4x4 mRot)

Member Function Documentation

Quaternion PLMath::Quaternion::operator+ ( const Quaternion qQ) const [inline]
Quaternion & PLMath::Quaternion::operator+= ( const Quaternion qQ) [inline]
Quaternion PLMath::Quaternion::operator- ( ) const [inline]
Quaternion PLMath::Quaternion::operator- ( const Quaternion qQ) const [inline]
Quaternion & PLMath::Quaternion::operator-= ( const Quaternion qQ) [inline]
Quaternion PLMath::Quaternion::operator* ( float  f) const [inline]
Quaternion & PLMath::Quaternion::operator*= ( float  f) [inline]
Quaternion PLMath::Quaternion::operator* ( const Quaternion qQ) const [inline]
Quaternion & PLMath::Quaternion::operator*= ( const Quaternion qQ) [inline]
Vector3 PLMath::Quaternion::operator* ( const Vector3 vV) const [inline]
Vector4 PLMath::Quaternion::operator* ( const Vector4 vV) const [inline]
Quaternion PLMath::Quaternion::operator/ ( float  f) const [inline]
Quaternion & PLMath::Quaternion::operator/= ( float  f) [inline]
Quaternion & PLMath::Quaternion::operator= ( const Quaternion qQ) [inline]
bool PLMath::Quaternion::operator== ( const Quaternion qQ) const [inline]
bool PLMath::Quaternion::operator!= ( const Quaternion qQ) const [inline]
PLMath::Quaternion::operator float * ( ) [inline]
PLMath::Quaternion::operator const float * ( ) const [inline]
Quaternion & PLMath::Quaternion::SetWXYZ ( float  fW,
float  fX,
float  fY,
float  fZ 
) [inline]

Sets the component of the quaternion.

Parameters:
[in]fWW component
[in]fXX component
[in]fYY component
[in]fZZ component
Returns:
This quaternion
Quaternion & PLMath::Quaternion::SetWXYZ ( const float  fValues[]) [inline]

Sets the component of the quaternion.

Parameters:
[in]fValuesArray of at least 4 floats
Returns:
This quaternion
PLMATH_API void PLMath::Quaternion::ToAxisAngle ( float &  fX,
float &  fY,
float &  fZ,
float &  fAngle 
) const

Returns a selected axis and angle from the rotation quaternion.

Parameters:
[out]fXWill receive the x component of the selected axis
[out]fYWill receive the y component of the selected axis
[out]fZWill receive the z component of the selected axis
[out]fAngleWill receive the rotation angle around the selected axis (in radian, between [0, Math::Pi])
Note:
  • The quaternion must be normalized
PLMATH_API Quaternion& PLMath::Quaternion::FromAxisAngle ( float  fX,
float  fY,
float  fZ,
float  fAngle 
)

Sets a rotation quaternion by using a selected axis and angle.

Parameters:
[in]fXX component of the selected axis
[in]fYY component of the selected axis
[in]fZZ component of the selected axis
[in]fAngleRotation angle around the selected axis (in radian, between [0, Math::Pi])
Returns:
This quaternion
Note:
  • The given selected axis must be normalized!
PLMATH_API Vector3 PLMath::Quaternion::GetXAxis ( ) const

Returns the x (left) axis.

Returns:
The x (left) axis, already normalized for rotation quaternions
PLMATH_API Vector3 PLMath::Quaternion::GetYAxis ( ) const

Returns the y (up) axis.

Returns:
The y (up) axis, already normalized for rotation quaternions
PLMATH_API Vector3 PLMath::Quaternion::GetZAxis ( ) const

Returns the z (forward) axis.

Returns:
The z (forward) axis, already normalized for rotation quaternions
PLMATH_API void PLMath::Quaternion::ToRotationMatrix ( Matrix3x3 mRot) const

Returns the rotation quaternion as 3x3 matrix.

Parameters:
[out]mRotWill receive the rotation matrix

Sets a rotation quaternion by using a 3x3 rotation matrix.

Parameters:
[in]mRotRotation matrix
Returns:
This quaternion
PLMATH_API void PLMath::Quaternion::ToRotationMatrix ( Matrix3x4 mRot) const

Returns the rotation quaternion as 3x4 matrix.

Parameters:
[out]mRotWill receive the rotation matrix

Sets a rotation quaternion by using a 3x4 rotation matrix.

Parameters:
[in]mRotRotation matrix
Returns:
This quaternion
PLMATH_API void PLMath::Quaternion::ToRotationMatrix ( Matrix4x4 mRot) const

Returns the rotation quaternion as 4x4 matrix.

Parameters:
[out]mRotWill receive the rotation matrix

Sets a rotation quaternion by using a 4x4 rotation matrix.

Parameters:
[in]mRotRotation matrix
Returns:
This quaternion
bool PLMath::Quaternion::Compare ( const Quaternion qQ,
float  fEpsilon = Math::Epsilon 
) const [inline]

Compares two quaternions using an epsilon environment.

Parameters:
[in]qQQuaternion to compare with
[in]fEpsilonEpsilon environment
Returns:
'true' if the both quaternions are equal, else 'false'
float PLMath::Quaternion::GetLength ( ) const [inline]

Returns the length (also called magnitude) of the quaternion.

Returns:
The length (also called magnitude) of the quaternion
float PLMath::Quaternion::GetSquaredLength ( ) const [inline]

Returns the squared length (norm) of the quaternion.

Returns:
The squared length (norm) of the quaternion
float PLMath::Quaternion::DotProduct ( const Quaternion qQ) const [inline]

Returns the dot product of this quaternion and another one.

Parameters:
[in]qQSecond quaternion
Returns:
The dot product of the two quaternions

Normalizes the quaternion.

Normalizes the vector.

Returns:
This quaternion

Returns a normalized quaternion.

Returns:
Normalized quaternion
void PLMath::Quaternion::Conjugate ( ) [inline]

Conjugates the quaternion.

Returns the conjugated of the quaternion.

Returns:
The conjugated of the quaternion
void PLMath::Quaternion::Invert ( ) [inline]

Inverts the quaternion.

Returns the inverted quaternion.

Returns:
Inverted quaternion
void PLMath::Quaternion::UnitInvert ( ) [inline]

Inverts the normalized quaternion.

Remarks:
This function can only be used if the quaternion is normalized! (rotation quaternions are normally always normalized) If the quaternion is not normalized, use Invert() instead.

Returns the inverted normalized quaternion.

Returns:
Inverted normalized quaternion
See also:

Calculates the exponential of the quaternion.

Returns:
This quaternion

Returns the exponential of the quaternion.

Returns:
The exponential of the quaternion
Quaternion & PLMath::Quaternion::Power ( float  fPower) [inline]

Calculates the power of the quaternion.

Parameters:
[in]fPowerPower to calculate
Returns:
This quaternion
Quaternion PLMath::Quaternion::GetPower ( float  fPower) const [inline]

Returns the power of the quaternion.

Parameters:
[in]fPowerPower to calculate
Returns:
The power of the quaternion
PLMATH_API void PLMath::Quaternion::Slerp ( const Quaternion qQ1,
const Quaternion qQ2,
float  fTime 
)

Computes spherical linear interpolation between qQ1 and qQ2 with time 0-1.

Parameters:
[in]qQ1Start quaternion (time: 0)
[in]qQ2End quaternion (time: 1)
[in]fTimeTime from 0-1

To string.

Returns:
String with the data
PLMATH_API bool PLMath::Quaternion::FromString ( const PLCore::String sString)

From string.

Parameters:
[in]sStringString with the data

Member Data Documentation

PLMATH_API const Quaternion PLMath::Quaternion::Zero [static]

0.0, 0.0, 0.0, 0.0

PLMATH_API const Quaternion PLMath::Quaternion::Identity [static]

1.0, 0.0, 0.0, 0.0

union { ... }

Some direct quaternion element accesses.


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


PixelLight PixelLight 0.9.11-R1
Copyright (C) 2002-2012 by The PixelLight Team
Last modified Thu Feb 23 2012 14:09:36
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported