GL Studio C++ Runtime API
GlsQuaternion< Type > Class Template Reference

#include <gls_quaternion.h>

Public Member Functions

 GlsQuaternion ()
 
 GlsQuaternion (Type x, Type y, Type z, Type w)
 
 GlsQuaternion (Type angle, const Vector &axis)
 
 GlsQuaternion (Type angle1, const Vector &axis1, Type angle2, const Vector &axis2, Type angle3, const Vector &axis3)
 
 GlsQuaternion (Type angleX, Type angleY, Type angleZ)
 
 GlsQuaternion (const Vector &anglesVec)
 
 GlsQuaternion (const GlsMatrixAffine< Type > &matrix)
 
Type * Data ()
 
const Type * Data () const
 
bool operator== (const GlsQuaternion &q) const
 
bool operator!= (const GlsQuaternion &q) const
 
bool operator< (const GlsQuaternion &q) const
 
const GlsQuaternion operator* (Type s) const
 
GlsQuaternionoperator*= (Type s)
 
const GlsQuaternion operator* (const GlsQuaternion &q) const
 
GlsQuaternionoperator*= (const GlsQuaternion &q)
 
GlsQuaternion operator/ (Type s) const
 
GlsQuaternionoperator/= (Type s)
 
const GlsQuaternion operator/ (const GlsQuaternion &q) const
 
GlsQuaternionoperator/= (const GlsQuaternion &q)
 
const GlsQuaternion operator+ (const GlsQuaternion &q) const
 
GlsQuaternionoperator+= (const GlsQuaternion &q)
 
const GlsQuaternion operator- (const GlsQuaternion &q) const
 
GlsQuaternionoperator-= (const GlsQuaternion &q)
 
const GlsQuaternion operator- () const
 
Type Magnitude () const
 
Type MagnitudeSquared () const
 
GlsQuaternion Conjugate () const
 
const GlsQuaternion Inverse () const
 
Type DotProduct (const GlsQuaternion &q) const
 
void Normalize ()
 
void Set (Type x, Type y, Type z, Type w)
 
void SetFromAngleAxis (Type angle, const Vector &axis)
 
void SetFromAngleAxis (Type angle1, const Vector &axis1, Type angle2, const Vector &axis2, Type angle3, const Vector &axis3)
 
void SetFromEulerAngles (Type angleX, Type angleY, Type angleZ)
 
void SetFromVectors (const Vector &to, const Vector &from)
 
void SetFromRotationMatrix (const GlsMatrixAffine< Type > &matrix)
 
Type GetRoll () const
 
Type GetPitch () const
 
Type GetYaw () const
 
Vector GetEulerAngles ()
 
void GetAngleAxis (Type *angle, Vector *axis)
 
GlsMatrixAffine< Type > GetRotationMatrix ()
 
void SetFromSlerp (float t, const GlsQuaternion &from, const GlsQuaternion &to, bool adjustSign=true)
 

Static Protected Member Functions

static bool IsVeryCloseToZero (double value)
 

Protected Attributes

Type _v [4]
 The four components of the quaternion.
 

Detailed Description

template<class Type>
class disti::GlsQuaternion< Type >

The GlsQuaternion class

Constructor & Destructor Documentation

◆ GlsQuaternion() [1/7]

GlsQuaternion ( )
inline

Default constructor. This will initialize the quaternion to zero.

◆ GlsQuaternion() [2/7]

GlsQuaternion ( Type  x,
Type  y,
Type  z,
Type  w 
)
inline

Constructor. Sets quaternion from 4 constants.

Parameters
xInitial X value
yInitial Y value
zInitial Z value
wInitial W value

◆ GlsQuaternion() [3/7]

GlsQuaternion ( Type  angle,
const Vector axis 
)
inline

Constructor. Sets quaternion from angle about an arbitrary axis

Parameters
angleRotation angle in radians
axisUnit vector representing arbitrary axis

◆ GlsQuaternion() [4/7]

GlsQuaternion ( Type  angle1,
const Vector axis1,
Type  angle2,
const Vector axis2,
Type  angle3,
const Vector axis3 
)
inline

Constructor. Sets quaternion from 3 angles about 3 axes

Parameters
angle1Rotation angle about first axis in radians
axis1Unit vector representing first arbitrary axis
angle2Rotation angle about second axis in radians
axis2Unit vector representing second arbitrary axis
angle3Rotation angle about third axis in radians
axis3Unit vector representing third arbitrary axis

◆ GlsQuaternion() [5/7]

GlsQuaternion ( Type  angleX,
Type  angleY,
Type  angleZ 
)
inline

Constructor. Sets quaternion from 3 angles (Euler Angles)

Parameters
angleXRotation angle about X axis in radians
angleYRotation angle about Y axis in radians
angleZRotation angle about Z axis in radians

◆ GlsQuaternion() [6/7]

GlsQuaternion ( const Vector anglesVec)
inline

Constructor. Sets quaternion from 3 angles (Euler Angles)

Parameters
anglesVecA vector where each component of the vector is an Euler angle component in radians.

◆ GlsQuaternion() [7/7]

GlsQuaternion ( const GlsMatrixAffine< Type > &  matrix)
inline

Constructor. Sets quaternion from a rotation matrix

Parameters
matrixAn affine matrix representing a rotation matrix

Member Function Documentation

◆ Conjugate()

GlsQuaternion Conjugate ( ) const
inline

Returns the conjugate of the quaternion

Returns
The conjugate of the quaternion

◆ Data() [1/2]

Type * Data ( )
inline

Accessor method providing access to quaternion data.

Returns
A pointer to the quaternion data.

◆ Data() [2/2]

const Type * Data ( ) const
inline

Accessor method providing access to quaternion data.

Returns
A pointer to the quaternion data.

◆ DotProduct()

Type DotProduct ( const GlsQuaternion< Type > &  q) const
inline

Returns the dot product of the quaternion and a supplied quaternion

Parameters
qA quaternion to multiply against this quaternion
Returns
The dot product of the quaternion and a supplied quaternion

◆ GetAngleAxis()

void GetAngleAxis ( Type *  angle,
Vector axis 
)
inline

Gets the rotation angle (radians) and the axis about which the angle is rotated.

Parameters
angleReturns the angle of rotation of the quaternion
axisReturns the axis of rotation of the quaternion

◆ GetEulerAngles()

Vector GetEulerAngles ( )
inline

Returns the Euler Angles as a Vector (Warning: SLOW)

Returns
The Euler Angles as a Vector

◆ GetPitch()

Type GetPitch ( ) const
inline

Returns the rotation about the Y axis

Returns
The rotation about the Y axis

◆ GetRoll()

Type GetRoll ( ) const
inline

Returns the rotation about the X axis

Returns
The rotation about the X axis

◆ GetRotationMatrix()

GlsMatrixAffine< Type > GetRotationMatrix ( )
inline

Returns a rotation matrix representation of the quaternion.

Returns
The rotation matrix computed from the quaternion

◆ GetYaw()

Type GetYaw ( ) const
inline

Returns the rotation about the Z axis

Returns
The rotation about the Z axis

◆ Inverse()

const GlsQuaternion Inverse ( ) const
inline

Returns the inverse of the quaternion

Returns
The inverse of the quaternion

◆ IsVeryCloseToZero()

static bool IsVeryCloseToZero ( double  value)
inlinestaticprotected

Circular dependancies prevent us from using VeryCloseToZero in util.h.

Parameters
valueThe value to compare.
Returns
True if the value if close enough to zero.

◆ Magnitude()

Type Magnitude ( ) const
inline

Returns the magnitude of the quaternion

Returns
The magnitude of the quaternion

◆ MagnitudeSquared()

Type MagnitudeSquared ( ) const
inline

Returns the magnitude squared of the quaternion

Returns
The magnitude squared of the quaternion

◆ Normalize()

void Normalize ( )
inline

Normalizes this quaternion

◆ operator!=()

bool operator!= ( const GlsQuaternion< Type > &  q) const
inline

Boolean non-equivalence operator

Parameters
qQuaternion to compare against
Returns
True if the two quaternions are not exactly equal

◆ operator*() [1/2]

const GlsQuaternion operator* ( const GlsQuaternion< Type > &  q) const
inline

The quaternion multiplication operator.

Parameters
qA quaternion to multiply against.
Returns
This quaternion multiplied by the quaternion.

◆ operator*() [2/2]

const GlsQuaternion operator* ( Type  s) const
inline

Scalar multiplication operator

Parameters
sA scalar to multiply against
Returns
This quaternion multiplied by the scalar

◆ operator*=() [1/2]

GlsQuaternion & operator*= ( const GlsQuaternion< Type > &  q)
inline

The quaternion multiplication operator.

Parameters
qA quaternion to multiply against.
Returns
This quaternion multiplied by the quaternion.

◆ operator*=() [2/2]

GlsQuaternion & operator*= ( Type  s)
inline

Scalar multiplication operator and assignment operator

Parameters
sA scalar to multiply against
Returns
This quaternion multiplied by the scalar

◆ operator+()

const GlsQuaternion operator+ ( const GlsQuaternion< Type > &  q) const
inline

Quaternion addition operator

Parameters
qA quaternion to add
Returns
This quaternion plus the supplied quaternion

◆ operator+=()

GlsQuaternion & operator+= ( const GlsQuaternion< Type > &  q)
inline

Quaternion addition and assignment operator

Parameters
qA quaternion to add
Returns
This quaternion plus the supplied quaternion

◆ operator-() [1/2]

const GlsQuaternion operator- ( ) const
inline

Negation operator - returns the negative of the quaternion. Basically just calls operator - () on the Vec4

Returns
The negated quaternion (this * -1).

◆ operator-() [2/2]

const GlsQuaternion operator- ( const GlsQuaternion< Type > &  q) const
inline

Quaternion subtrtaction operator

Parameters
qA quaternion to subtract
Returns
This quaternion minus the supplied quaternion

◆ operator-=()

GlsQuaternion & operator-= ( const GlsQuaternion< Type > &  q)
inline

Quaternion subtraction and assignment operator

Parameters
qA quaternion to subtract
Returns
This quaternion minus the supplied quaternion

◆ operator/() [1/2]

const GlsQuaternion operator/ ( const GlsQuaternion< Type > &  q) const
inline

Quaternion division operator

Parameters
qA quaternion to division by
Returns
This quaternion divided by the quaternion

◆ operator/() [2/2]

GlsQuaternion operator/ ( Type  s) const
inline

Scalar division operator

Parameters
sA scalar to divide
Returns
This quaternion divided by the scalar

◆ operator/=() [1/2]

GlsQuaternion & operator/= ( const GlsQuaternion< Type > &  q)
inline

Quaternion division operator

Parameters
qA quaternion to division by
Returns
This quaternion divided by the quaternion

◆ operator/=() [2/2]

GlsQuaternion & operator/= ( Type  s)
inline

Scalar division and assignment operator

Parameters
sA scalar to divide
Returns
This quaternion divided by the scalar

◆ operator<()

bool operator< ( const GlsQuaternion< Type > &  q) const
inline

Boolean less than operator

Parameters
qQuaternion to compare against
Returns
True if the this quaternion is less than the provided one

◆ operator==()

bool operator== ( const GlsQuaternion< Type > &  q) const
inline

Boolean equivalence operator

Parameters
qQuaternion to compare against
Returns
True if the two quaternions are exactly equal

◆ Set()

void Set ( Type  x,
Type  y,
Type  z,
Type  w 
)
inline

Sets the component values for this quaternion

Parameters
xThe X value
yThe Y value
zThe Z value
wThe W value

◆ SetFromAngleAxis() [1/2]

void SetFromAngleAxis ( Type  angle,
const Vector axis 
)
inline

Sets quaternion from angle about an arbitrary axis

Parameters
angleRotation angle in radians
axisUnit vector representing arbitrary axis

◆ SetFromAngleAxis() [2/2]

void SetFromAngleAxis ( Type  angle1,
const Vector axis1,
Type  angle2,
const Vector axis2,
Type  angle3,
const Vector axis3 
)
inline

Sets quaternion from three angle-axis pairs.

Parameters
angle1Rotation angle in radians
axis1Unit vector representing arbitrary axis
angle2Rotation angle in radians
axis2Unit vector representing arbitrary axis
angle3Rotation angle in radians
axis3Unit vector representing arbitrary axis

◆ SetFromEulerAngles()

void SetFromEulerAngles ( Type  angleX,
Type  angleY,
Type  angleZ 
)
inline

Sets quaternion from the Euler angles.

Parameters
angleXThe X Euler angle in radians
angleYThe Y Euler angle in radians
angleZThe Z Euler angle in radians

◆ SetFromRotationMatrix()

void SetFromRotationMatrix ( const GlsMatrixAffine< Type > &  matrix)
inline

Sets this quaternion from the specified rotation matrix.

Parameters
matrixThe rotation matrix

◆ SetFromSlerp()

void SetFromSlerp ( float  t,
const GlsQuaternion< Type > &  from,
const GlsQuaternion< Type > &  to,
bool  adjustSign = true 
)
inline

Sets this quaternion to an interpolated rotation between the from and to vectors using spherical linear interpolation (slerp).

Parameters
tPercent of interpelation (0.0 -> 1.0)
fromThe starting quaternion
toThe ending quaternion
adjustSignWhether or not to negate the sign of the to quaternion

◆ SetFromVectors()

void SetFromVectors ( const Vector to,
const Vector from 
)
inline

Sets this quaternion to a rotation that rotates 'to' into 'from'.

Parameters
toThe rotation destination
fromThe rotation start point

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