MinGfx Toolkit
1.0
A minimal library for writing cross-platform (Windows, OSX, linux) graphics programs.
|
A quaternion to represent rotations in 3D space.
The main use of quaternions within the library is to support smooth interpolation between rotations, since this is not possible using Euler angles or rotation matrices. The class includes a Slerp routine for spherical interpolation between rotations. Example use:
Definition at line 41 of file quaternion.h.
#include <quaternion.h>
Public Member Functions | |
Quaternion () | |
Creates a quat with the identity rotation. More... | |
Quaternion (float qx, float qy, float qz, float qw) | |
Creates a quat from the 4 parameters. More... | |
Quaternion (float *ptr) | |
Creates a quate from a pointer to 4 floating point numbers in the order qx, qy, qz, qw. More... | |
Quaternion (const Quaternion &other) | |
Copy constructor. More... | |
virtual | ~Quaternion () |
bool | operator== (const Quaternion &q) const |
Check for "equality", taking floating point imprecision into account. More... | |
bool | operator!= (const Quaternion &q) const |
Check for "inequality", taking floating point imprecision into account. More... | |
Quaternion & | operator= (const Quaternion &q) |
Assignment operator. More... | |
float | operator[] (const int i) const |
Read only access to the ith coordinate of the quaternion (qx, qy, qz, qw). More... | |
float & | operator[] (const int i) |
Writable access the ith coordinate of the quaternion (qx, qy, qz, qw). More... | |
float | x () const |
Read only access to the x coordinate of the imaginary part of the quaternion. More... | |
float | y () const |
Read only access to the y coordinate of the imaginary part of the quaternion. More... | |
float | z () const |
Read only access to the z coordinate of the imaginary part of the quaternion. More... | |
float | w () const |
Read only access to the w, real part, of the quaternion. More... | |
const float * | value_ptr () const |
Returns a const pointer to the raw data array, stored in the order qx, qy, qz, qw. More... | |
float | Dot (const Quaternion &q) const |
Returns the dot product of this quaternion with another. More... | |
float | Length () const |
Returns the length of the quaternion. More... | |
void | Normalize () |
Normalizes the quat by making it unit length. More... | |
Quaternion | ToUnit () const |
Returns a normalized (i.e., unit length) version of the quaternion without modifying the original. More... | |
Quaternion | Conjugate () const |
Returns the conjugate of the quaternion. More... | |
Vector3 | ToEulerAnglesZYX () const |
Converts the rotation specified by the quaternion into Euler angles. More... | |
Quaternion | Slerp (const Quaternion &other, float alpha) const |
Uses spherical interpolation to interpoloate between the rotation stored in this quaternion and the rotation stored in another. More... | |
Static Public Member Functions | |
static Quaternion | FromAxisAngle (const Vector3 &axis, float angle) |
Creates a new quaternion that describes a rotation by angle radians about. More... | |
static Quaternion | FromEulerAnglesZYX (const Vector3 &angles) |
Creates a new quaternion from a rotation defined in Euler angles. More... | |
static Quaternion | Slerp (const Quaternion &a, const Quaternion &b, float alpha) |
Uses spherical interpolation to interpoloate between the rotations specified by two quaternions. More... | |
mingfx::Quaternion::Quaternion | ( | ) |
Creates a quat with the identity rotation.
mingfx::Quaternion::Quaternion | ( | float | qx, |
float | qy, | ||
float | qz, | ||
float | qw | ||
) |
Creates a quat from the 4 parameters.
mingfx::Quaternion::Quaternion | ( | float * | ptr | ) |
Creates a quate from a pointer to 4 floating point numbers in the order qx, qy, qz, qw.
mingfx::Quaternion::Quaternion | ( | const Quaternion & | other | ) |
Copy constructor.
|
virtual |
Quaternion mingfx::Quaternion::Conjugate | ( | ) | const |
Returns the conjugate of the quaternion.
float mingfx::Quaternion::Dot | ( | const Quaternion & | q | ) | const |
Returns the dot product of this quaternion with another.
|
static |
Creates a new quaternion that describes a rotation by angle radians about.
|
static |
Creates a new quaternion from a rotation defined in Euler angles.
float mingfx::Quaternion::Length | ( | ) | const |
Returns the length of the quaternion.
void mingfx::Quaternion::Normalize | ( | ) |
Normalizes the quat by making it unit length.
bool mingfx::Quaternion::operator!= | ( | const Quaternion & | q | ) | const |
Check for "inequality", taking floating point imprecision into account.
Quaternion& mingfx::Quaternion::operator= | ( | const Quaternion & | q | ) |
Assignment operator.
bool mingfx::Quaternion::operator== | ( | const Quaternion & | q | ) | const |
Check for "equality", taking floating point imprecision into account.
float& mingfx::Quaternion::operator[] | ( | const int | i | ) |
Writable access the ith coordinate of the quaternion (qx, qy, qz, qw).
float mingfx::Quaternion::operator[] | ( | const int | i | ) | const |
Read only access to the ith coordinate of the quaternion (qx, qy, qz, qw).
|
static |
Uses spherical interpolation to interpoloate between the rotations specified by two quaternions.
Quaternion mingfx::Quaternion::Slerp | ( | const Quaternion & | other, |
float | alpha | ||
) | const |
Uses spherical interpolation to interpoloate between the rotation stored in this quaternion and the rotation stored in another.
Vector3 mingfx::Quaternion::ToEulerAnglesZYX | ( | ) | const |
Converts the rotation specified by the quaternion into Euler angles.
Quaternion mingfx::Quaternion::ToUnit | ( | ) | const |
Returns a normalized (i.e., unit length) version of the quaternion without modifying the original.
const float* mingfx::Quaternion::value_ptr | ( | ) | const |
Returns a const pointer to the raw data array, stored in the order qx, qy, qz, qw.
|
inline |
Read only access to the w, real part, of the quaternion.
Definition at line 83 of file quaternion.h.
|
inline |
Read only access to the x coordinate of the imaginary part of the quaternion.
Definition at line 74 of file quaternion.h.
|
inline |
Read only access to the y coordinate of the imaginary part of the quaternion.
Definition at line 77 of file quaternion.h.
|
inline |
Read only access to the z coordinate of the imaginary part of the quaternion.
Definition at line 80 of file quaternion.h.