| GL Studio C++ Runtime API

Public Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
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
GlsQuaternion & | operator*= (Type s)
const GlsQuaternion | operator* (const GlsQuaternion &q) const
GlsQuaternion & | operator*= (const GlsQuaternion &q)
GlsQuaternion | operator/ (Type s) const
GlsQuaternion & | operator/= (Type s)
const GlsQuaternion | operator/ (const GlsQuaternion &q) const
GlsQuaternion & | operator/= (const GlsQuaternion &q)
const GlsQuaternion | operator+ (const GlsQuaternion &q) const
GlsQuaternion & | operator+= (const GlsQuaternion &q)
const GlsQuaternion | operator- (const GlsQuaternion &q) const
GlsQuaternion & | operator-= (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

  x | Initial X value
  y | Initial Y value
  z | Initial Z value
  w | Initial W value

## ◆ GlsQuaternion() [3/7]

GlsQuaternion | ( | Type | angle,
|  | const Vector & | axis
| ) |  |
| inline

Constructor. Sets quaternion from angle about an arbitrary axis

Parameters

  angle | Rotation angle in radians
  axis | Unit 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

  angle1 | Rotation angle about first axis in radians
  axis1 | Unit vector representing first arbitrary axis
  angle2 | Rotation angle about second axis in radians
  axis2 | Unit vector representing second arbitrary axis
  angle3 | Rotation angle about third axis in radians
  axis3 | Unit 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

  angleX | Rotation angle about X axis in radians
  angleY | Rotation angle about Y axis in radians
  angleZ | Rotation angle about Z axis in radians

## ◆ GlsQuaternion() [6/7]

GlsQuaternion | ( | const Vector & | anglesVec | ) |
| inline

Constructor. Sets quaternion from 3 angles (Euler Angles)

Parameters

  anglesVec | A 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

  matrix | An 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

  q | A 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

  angle | Returns the angle of rotation of the quaternion
  axis | Returns 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 | ) |
| inline static protected

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

Parameters

  value | The 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

  q | Quaternion 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

  q | A 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

  s | A 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

  q | A 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

  s | A 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

  q | A quaternion to add

Returns
  This quaternion plus the supplied quaternion

## ◆ operator+=()

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

Quaternion addition and assignment operator

Parameters

  q | A 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

  q | A quaternion to subtract

Returns
  This quaternion minus the supplied quaternion

## ◆ operator-=()

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

Quaternion subtraction and assignment operator

Parameters

  q | A 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

  q | A quaternion to division by

Returns
  This quaternion divided by the quaternion

## ◆ operator/() [2/2]

GlsQuaternion operator/ | ( | Type | s | ) | const
| inline

Scalar division operator

Parameters

  s | A scalar to divide

Returns
  This quaternion divided by the scalar

## ◆ operator/=() [1/2]

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

Quaternion division operator

Parameters

  q | A 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

  s | A scalar to divide

Returns
  This quaternion divided by the scalar

## ◆ operator<()

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

Boolean less than operator

Parameters

  q | Quaternion 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

  q | Quaternion 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

  x | The X value
  y | The Y value
  z | The Z value
  w | The W value

## ◆ SetFromAngleAxis() [1/2]

void SetFromAngleAxis | ( | Type | angle,
|  | const Vector & | axis
| ) |  |
| inline

Sets quaternion from angle about an arbitrary axis

Parameters

  angle | Rotation angle in radians
  axis | Unit 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

  angle1 | Rotation angle in radians
  axis1 | Unit vector representing arbitrary axis
  angle2 | Rotation angle in radians
  axis2 | Unit vector representing arbitrary axis
  angle3 | Rotation angle in radians
  axis3 | Unit vector representing arbitrary axis

## ◆ SetFromEulerAngles()

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

Sets quaternion from the Euler angles.

Parameters

  angleX | The X Euler angle in radians
  angleY | The Y Euler angle in radians
  angleZ | The Z Euler angle in radians

## ◆ SetFromRotationMatrix()

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

Sets this quaternion from the specified rotation matrix.

Parameters

  matrix | The 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

  t | Percent of interpelation (0.0 -> 1.0)
  from | The starting quaternion
  to | The ending quaternion
  adjustSign | Whether 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

  to | The rotation destination
  from | The rotation start point

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

- gls_quaternion.h