Drag[en]gine Game Engine  1.0
decQuaternion Class Reference

4 Component Quaternion. More...

#include <decQuaternion.h>

Public Member Functions

Constructors and Destructors
 decQuaternion ()
 
 decQuaternion (float nx, float ny, float nz, float nw)
 
 decQuaternion (const decQuaternion &q)
 
Management
float Length () const
 
void Normalize ()
 
decQuaternion Normalized () const
 Retrieves the normalized quaternion. More...
 
decQuaternion Conjugate () const
 Retrieves the 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
 
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 ()
 
void Set (float nx, float ny, float nz, float nw)
 
void Set (const decQuaternion &q)
 
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...
 
Operators
decQuaternion operator- () const
 
decQuaternionoperator= (const decQuaternion &q)
 
decQuaternionoperator+= (const decQuaternion &q)
 
decQuaternionoperator-= (const decQuaternion &q)
 
decQuaternionoperator*= (float k)
 
decQuaternionoperator*= (const decQuaternion &q)
 
decQuaternionoperator/= (float k)
 
decQuaternion operator+ (const decQuaternion &q) const
 
decQuaternion operator- (const decQuaternion &q) const
 
decQuaternion operator* (float k) const
 
decQuaternion operator* (const decQuaternion &q) const
 
decQuaternion operator/ (float k) const
 
decVector operator* (const decVector &v) const
 
decDVector operator* (const decDVector &v) const
 
bool operator< (const decQuaternion &q) const
 
bool operator> (const decQuaternion &q) const
 
bool operator<= (const decQuaternion &q) const
 
bool operator>= (const decQuaternion &q) const
 

Static Public Member Functions

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

Public Attributes

float w
 
float x
 
float y
 
float z
 

Detailed Description

4 Component Quaternion.

Author
Pl├╝ss Roland
Version
1.0
Date
2014

Constructor & Destructor Documentation

◆ decQuaternion() [1/3]

decQuaternion::decQuaternion ( )

Creates a new quaternion initialized to no rotation.

◆ decQuaternion() [2/3]

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

Creates a new quaternion with the given values.

◆ decQuaternion() [3/3]

decQuaternion::decQuaternion ( const decQuaternion q)

Creates a 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

Retrieves the conjugation of this quaternion.

This yields the inverse rotation of the quaterion.

◆ CreateFromEuler() [1/2]

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

Creates a new quaternion from euler angles.

◆ CreateFromEuler() [2/2]

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

Creates a new quaternion from euler angles.

◆ CreateFromEulerX()

static decQuaternion decQuaternion::CreateFromEulerX ( float  angle)
static

Creates a new quaternion from an euler angle around the x axis.

◆ CreateFromEulerY()

static decQuaternion decQuaternion::CreateFromEulerY ( float  angle)
static

Creates a new quaternion from an euler angle around the y axis.

◆ CreateFromEulerZ()

static decQuaternion decQuaternion::CreateFromEulerZ ( float  angle)
static

Creates a 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

Retrieves the length of the quaternion.

◆ Normalize()

void decQuaternion::Normalize ( )

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

◆ Normalized()

decQuaternion decQuaternion::Normalized ( ) const

Retrieves the normalized quaternion.

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

◆ operator*() [1/4]

decQuaternion decQuaternion::operator* ( float  k) const

Retrieves a new quaternion with this quaternion scaled by k.

◆ operator*() [2/4]

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

Retrieves a new quaternion with this quaternion multiplied by another quaternion.

◆ operator*() [3/4]

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

Rotate a vector by this quaternion.

◆ operator*() [4/4]

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

Rotate a vector by this quaternion.

◆ operator*=() [1/2]

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

Multiplies the components of this quaternion with a value k.

◆ operator*=() [2/2]

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

Multiply this quaternion with another quaternion.

◆ operator+()

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

Retrieves a new 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

Retrieves the negation of this quaternion.

◆ operator-() [2/2]

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

Retrieves a new 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

Retrieves a new quaternion with this quaternion divided by k. If k is 0 an exception is thrown.

◆ operator/=()

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

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

◆ operator<()

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

Determines if all the components of this quaternion are less then the components of another one.

◆ operator<=()

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

Determines if all the components of this quaternion are less then or equal to the components of another one.

◆ operator=()

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

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

◆ operator>()

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

Determines if all the components of this quaternion are greater then the components of another one.

◆ operator>=()

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

Determines if all the components of this quaternion 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 ( float  nx,
float  ny,
float  nz,
float  nw 
)

Sets the components to the given values.

◆ Set() [2/2]

void decQuaternion::Set ( const decQuaternion q)

Sets the quaternion from another one.

◆ SetFromEuler() [1/2]

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

Set from euler angles.

◆ SetFromEuler() [2/2]

void decQuaternion::SetFromEuler ( const decVector angles)

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: