Drag[en]gine Game Engine  1.21
decQuaternion Class Reference

4 Component Quaternion. More...

#include <decQuaternion.h>

Public Member Functions

Constructors and Destructors
 decQuaternion ()
 Create new quaternion initialized to no rotation. More...
 
 decQuaternion (float nx, float ny, float nz, float nw)
 Create new quaternion with the given values. More...
 
 decQuaternion (const decQuaternion &q)
 Create new quaternion with the values of another quaternion. More...
 
Management
float Length () const
 Length of the quaternion. More...
 
void Normalize ()
 
decQuaternion Normalized () const
 Normalized quaternion. More...
 
decQuaternion Conjugate () const
 Conjugation of this quaternion. More...
 
const decQuaternion Absolute () const
 Retrieves absolute quaternion. More...
 
float Dot (const decQuaternion &q) const
 Dot-product. More...
 
const decVector GetEulerAngles () const
 Retrieves quaternion as euler angles. More...
 
decQuaternion Slerp (const decQuaternion &other, float factor) const
 Calculates the slerp of this quaternion with another given an interpolation factor. More...
 
bool IsEqualTo (const decQuaternion &q, float threshold=QUATERNION_THRESHOLD) const
 Two quaternions are equal component wise with respect to a threshold. More...
 
bool SameRotation (const decQuaternion &q, float threshold=QUATERNION_THRESHOLD) const
 Two quaternions represent the same rotation with respect to a threshold. More...
 
void SetZero ()
 Sets all components to 0 and w to 1. More...
 
void Set (float nx, float ny, float nz, float nw)
 Set components to the given values. More...
 
void Set (const decQuaternion &q)
 Set quaternion from another one. More...
 
void SetFromEuler (float rx, float ry, float rz)
 Set from euler angles. More...
 
void SetFromEuler (const decVector &angles)
 Set from euler angles. More...
 
void SetFromEulerX (float angle)
 Set from an euler angle around the x axis. More...
 
void SetFromEulerY (float angle)
 Set from an euler angle around the y axis. More...
 
void SetFromEulerZ (float angle)
 Set from an euler angle around the z axis. More...
 
void SetFromAxis (const decVector &axis, float angle)
 Set from axis and rotation angle around axis. More...
 
Operators
decQuaternion operator- () const
 Negation of this quaternion. More...
 
decQuaternionoperator= (const decQuaternion &q)
 Set components of this quaternion to the values of another one. More...
 
decQuaternionoperator+= (const decQuaternion &q)
 Adds the components of another quaternion to this one. More...
 
decQuaternionoperator-= (const decQuaternion &q)
 Subtracts the components of another quaternion from this quaternion. More...
 
decQuaternionoperator*= (float k)
 Multiplies the components of this quaternion with a value k. More...
 
decQuaternionoperator*= (const decQuaternion &q)
 Multiply this quaternion with another quaternion. More...
 
decQuaternionoperator/= (float k)
 Divides components by a value k. If the value k is 0 an exception is thrown. More...
 
decQuaternion operator+ (const decQuaternion &q) const
 Quaternion with the sum of this quaternion with another one. More...
 
decQuaternion operator- (const decQuaternion &q) const
 Quaternion with the difference of this quaternion to another one. More...
 
decQuaternion operator* (float k) const
 Quaternion scaled by k. More...
 
decQuaternion operator* (const decQuaternion &q) const
 Quaternion multiplied by another quaternion. More...
 
decQuaternion operator/ (float k) const
 Quaternion divided by k. If k is 0 an exception is thrown. More...
 
decVector operator* (const decVector &v) const
 Rotate a vector by this quaternion. More...
 
decDVector operator* (const decDVector &v) const
 Rotate a vector by this quaternion. More...
 
bool operator< (const decQuaternion &q) const
 All components are less then the components of another one. More...
 
bool operator> (const decQuaternion &q) const
 All components are greater then the components of another one. More...
 
bool operator<= (const decQuaternion &q) const
 All components are less then or equal to the components of another one. More...
 
bool operator>= (const decQuaternion &q) const
 All components are greater then or equal to the components of another one. More...
 

Static Public Member Functions

Quaternion Creation
static decQuaternion CreateFromEuler (float rx, float ry, float rz)
 Create new quaternion from euler angles. More...
 
static decQuaternion CreateFromEuler (const decVector &angles)
 Create new quaternion from euler angles. More...
 
static decQuaternion CreateFromEulerX (float angle)
 Create new quaternion from an euler angle around the x axis. More...
 
static decQuaternion CreateFromEulerY (float angle)
 Create new quaternion from an euler angle around the y axis. More...
 
static decQuaternion CreateFromEulerZ (float angle)
 Create new quaternion from an euler angle around the z axis. More...
 
static decQuaternion CreateFromAxis (const decVector &axis, float angle)
 Create from axis and rotation angle around axis. More...
 

Public Attributes

float w
 W Component of quaternion. More...
 
float x
 X Component of quaternion. More...
 
float y
 Y Component of quaternion. More...
 
float z
 Z Component of quaternion. More...
 

Detailed Description

4 Component Quaternion.

Constructor & Destructor Documentation

◆ decQuaternion() [1/3]

decQuaternion::decQuaternion ( )

Create new quaternion initialized to no rotation.

◆ decQuaternion() [2/3]

decQuaternion::decQuaternion ( float  nx,
float  ny,
float  nz,
float  nw 
)

Create new quaternion with the given values.

◆ decQuaternion() [3/3]

decQuaternion::decQuaternion ( const decQuaternion q)

Create new quaternion with the values of another quaternion.

Member Function Documentation

◆ Absolute()

const decQuaternion decQuaternion::Absolute ( ) const

Retrieves absolute quaternion.

◆ Conjugate()

decQuaternion decQuaternion::Conjugate ( ) const

Conjugation of this quaternion.

This yields the inverse rotation of the quaterion.

◆ CreateFromAxis()

static decQuaternion decQuaternion::CreateFromAxis ( const decVector axis,
float  angle 
)
static

Create from axis and rotation angle around axis.

◆ CreateFromEuler() [1/2]

static decQuaternion decQuaternion::CreateFromEuler ( const decVector angles)
static

Create new quaternion from euler angles.

◆ CreateFromEuler() [2/2]

static decQuaternion decQuaternion::CreateFromEuler ( float  rx,
float  ry,
float  rz 
)
static

Create new quaternion from euler angles.

◆ CreateFromEulerX()

static decQuaternion decQuaternion::CreateFromEulerX ( float  angle)
static

Create new quaternion from an euler angle around the x axis.

◆ CreateFromEulerY()

static decQuaternion decQuaternion::CreateFromEulerY ( float  angle)
static

Create new quaternion from an euler angle around the y axis.

◆ CreateFromEulerZ()

static decQuaternion decQuaternion::CreateFromEulerZ ( float  angle)
static

Create new quaternion from an euler angle around the z axis.

◆ Dot()

float decQuaternion::Dot ( const decQuaternion q) const

Dot-product.

◆ GetEulerAngles()

const decVector decQuaternion::GetEulerAngles ( ) const

Retrieves quaternion as euler angles.

Warning
The result is only correct if the quaternion is normalized.

◆ IsEqualTo()

bool decQuaternion::IsEqualTo ( const decQuaternion q,
float  threshold = QUATERNION_THRESHOLD 
) const

Two quaternions are equal component wise with respect to a threshold.

◆ Length()

float decQuaternion::Length ( ) const

Length of the quaternion.

◆ Normalize()

void decQuaternion::Normalize ( )

\breief Normalize quaternion.

If the length of the quaternion is 0 an exception is thrown.

◆ Normalized()

decQuaternion decQuaternion::Normalized ( ) const

Normalized quaternion.

If the length of the quaterion is 0 an exception is thrown.

◆ operator*() [1/4]

decDVector decQuaternion::operator* ( const decDVector v) const

Rotate a vector by this quaternion.

◆ operator*() [2/4]

decQuaternion decQuaternion::operator* ( const decQuaternion q) const

Quaternion multiplied by another quaternion.

◆ operator*() [3/4]

decVector decQuaternion::operator* ( const decVector v) const

Rotate a vector by this quaternion.

◆ operator*() [4/4]

decQuaternion decQuaternion::operator* ( float  k) const

Quaternion scaled by k.

◆ operator*=() [1/2]

decQuaternion& decQuaternion::operator*= ( const decQuaternion q)

Multiply this quaternion with another quaternion.

◆ operator*=() [2/2]

decQuaternion& decQuaternion::operator*= ( float  k)

Multiplies the components of this quaternion with a value k.

◆ operator+()

decQuaternion decQuaternion::operator+ ( const decQuaternion q) const

Quaternion with the sum of this quaternion with another one.

◆ operator+=()

decQuaternion& decQuaternion::operator+= ( const decQuaternion q)

Adds the components of another quaternion to this one.

◆ operator-() [1/2]

decQuaternion decQuaternion::operator- ( ) const

Negation of this quaternion.

◆ operator-() [2/2]

decQuaternion decQuaternion::operator- ( const decQuaternion q) const

Quaternion with the difference of this quaternion to another one.

◆ operator-=()

decQuaternion& decQuaternion::operator-= ( const decQuaternion q)

Subtracts the components of another quaternion from this quaternion.

◆ operator/()

decQuaternion decQuaternion::operator/ ( float  k) const

Quaternion divided by k. If k is 0 an exception is thrown.

◆ operator/=()

decQuaternion& decQuaternion::operator/= ( float  k)

Divides components by a value k. If the value k is 0 an exception is thrown.

◆ operator<()

bool decQuaternion::operator< ( const decQuaternion q) const

All components are less then the components of another one.

◆ operator<=()

bool decQuaternion::operator<= ( const decQuaternion q) const

All components are less then or equal to the components of another one.

◆ operator=()

decQuaternion& decQuaternion::operator= ( const decQuaternion q)

Set components of this quaternion to the values of another one.

◆ operator>()

bool decQuaternion::operator> ( const decQuaternion q) const

All components are greater then the components of another one.

◆ operator>=()

bool decQuaternion::operator>= ( const decQuaternion q) const

All components are greater then or equal to the components of another one.

◆ SameRotation()

bool decQuaternion::SameRotation ( const decQuaternion q,
float  threshold = QUATERNION_THRESHOLD 
) const

Two quaternions represent the same rotation with respect to a threshold.

Same as

a.IsEqualTo(b) || a.IsEqualTo(-b)

. In particular quaternions of the same rotation are not required to be equal.

◆ Set() [1/2]

void decQuaternion::Set ( const decQuaternion q)

Set quaternion from another one.

◆ Set() [2/2]

void decQuaternion::Set ( float  nx,
float  ny,
float  nz,
float  nw 
)

Set components to the given values.

◆ SetFromAxis()

void decQuaternion::SetFromAxis ( const decVector axis,
float  angle 
)

Set from axis and rotation angle around axis.

◆ SetFromEuler() [1/2]

void decQuaternion::SetFromEuler ( const decVector angles)

Set from euler angles.

◆ SetFromEuler() [2/2]

void decQuaternion::SetFromEuler ( float  rx,
float  ry,
float  rz 
)

Set from euler angles.

◆ SetFromEulerX()

void decQuaternion::SetFromEulerX ( float  angle)

Set from an euler angle around the x axis.

◆ SetFromEulerY()

void decQuaternion::SetFromEulerY ( float  angle)

Set from an euler angle around the y axis.

◆ SetFromEulerZ()

void decQuaternion::SetFromEulerZ ( float  angle)

Set from an euler angle around the z axis.

◆ SetZero()

void decQuaternion::SetZero ( )

Sets all components to 0 and w to 1.

◆ Slerp()

decQuaternion decQuaternion::Slerp ( const decQuaternion other,
float  factor 
) const

Calculates the slerp of this quaternion with another given an interpolation factor.

Member Data Documentation

◆ w

float decQuaternion::w

W Component of quaternion.

◆ x

float decQuaternion::x

X Component of quaternion.

◆ y

float decQuaternion::y

Y Component of quaternion.

◆ z

float decQuaternion::z

Z Component of quaternion.


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