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 (void) const
 
Type GetPitch (void) const
 
Type GetYaw (void) 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)
 

Detailed Description

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

The GlsQuaternion class

Constructor & Destructor Documentation

GlsQuaternion ( )
inline

Default constructor. This will initialize the quaternion to zero.

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 ( 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 ( 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 ( 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 ( 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 ( const GlsMatrixAffine< Type > &  matrix)
inline

Constructor. Sets quaternion from a rotation matrix

Parameters
matrixAn affine matrix representing a rotation matrix

Member Function Documentation

GlsQuaternion Conjugate ( ) const
inline

Returns the conjugate of the quaternion

Returns
The conjugate of the quaternion
Type* Data ( )
inline

Accessor method providing access to quaternion data.

Returns
A pointer to the quaternion data.
const Type* Data ( ) const
inline

Accessor method providing access to quaternion data.

Returns
A pointer to the quaternion data.
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
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
Vector GetEulerAngles ( )
inline

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

Returns
The Euler Angles as a Vector
Type GetPitch ( void  ) const
inline

Returns the rotation about the Y axis

Returns
The rotation about the Y axis
Type GetRoll ( void  ) const
inline

Returns the rotation about the X axis

Returns
The rotation about the X axis
GlsMatrixAffine<Type> GetRotationMatrix ( )
inline

Returns a rotation matrix representation of the quaternion.

Returns
The rotation matrix computed from the quaternion
Type GetYaw ( void  ) const
inline

Returns the rotation about the Z axis

Returns
The rotation about the Z axis
const GlsQuaternion Inverse ( ) const
inline

Returns the inverse of the quaternion

Returns
The inverse of the quaternion
Type Magnitude ( ) const
inline

Returns the magnitude of the quaternion

Returns
The magnitude of the quaternion
Type MagnitudeSquared ( ) const
inline

Returns the magnitude squared of the quaternion

Returns
The magnitude squared of the quaternion
void Normalize ( )
inline

Normalizes this quaternion

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
const GlsQuaternion operator* ( Type  s) const
inline

Scalar multiplication operator

Parameters
sA scalar to multiply against
Returns
This quaternion multiplied by the scalar
const GlsQuaternion operator* ( const GlsQuaternion< Type > &  q) const
inline

Quaternion multiplication operator

Parameters
qA quaternion to multiply against
Returns
This quaternion multiplied by the quaternion
GlsQuaternion& operator*= ( Type  s)
inline

Scalar multiplication operator and assignment operator

Parameters
sA scalar to multiply against
Returns
This quaternion multiplied by the scalar
GlsQuaternion& operator*= ( const GlsQuaternion< Type > &  q)
inline

Quaternion multiplication operator

Parameters
qA quaternion to multiply against
Returns
This quaternion multiplied by the quaternion
const GlsQuaternion operator+ ( const GlsQuaternion< Type > &  q) const
inline

Quaternion addition operator

Parameters
qA quaternion to add
Returns
This quaternion plus the supplied quaternion
GlsQuaternion& operator+= ( const GlsQuaternion< Type > &  q)
inline

Quaternion addition and assignment operator

Parameters
qA quaternion to add
Returns
This quaternion plus the supplied quaternion
const GlsQuaternion operator- ( const GlsQuaternion< Type > &  q) const
inline

Quaternion subtrtaction operator

Parameters
qA quaternion to subtract
Returns
This quaternion minus the supplied quaternion
const GlsQuaternion operator- ( ) const
inline

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

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

Quaternion subtraction and assignment operator

Parameters
qA quaternion to subtract
Returns
This quaternion minus the supplied quaternion
GlsQuaternion operator/ ( Type  s) const
inline

Scalar division operator

Parameters
sA scalar to divide
Returns
This quaternion divided by the scalar
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
GlsQuaternion& operator/= ( Type  s)
inline

Scalar division and assignment operator

Parameters
sA scalar to divide
Returns
This quaternion divided by the scalar
GlsQuaternion& operator/= ( const GlsQuaternion< Type > &  q)
inline

Quaternion division operator

Parameters
qA quaternion to division by
Returns
This quaternion divided by the quaternion
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
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
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
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
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
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
void SetFromRotationMatrix ( const GlsMatrixAffine< Type > &  matrix)
inline

Sets this quaternion from the specified rotation matrix.

Parameters
matrixThe rotation matrix
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
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: