![]() |
Murl Engine API
Version 2018.3
|
A quaternion class. More...
#include <murl_math_quaternion.h>
A quaternion class.
Public Types | |
enum | Component { R, I, J, K, NUM_COMPONENTS } |
Enumeration of the components raw data index. More... | |
enum | ComponentMask { MASK_NONE, MASK_R, MASK_I, MASK_J, MASK_K, MASK_IJK, MASK_ALL } |
Enumeration of the components' bit masks. More... | |
enum | PredefinedType { UNINITIALIZED, IDENTITY } |
Enumeration of the predefined initialization types for constructing a Quaternion(PredefinedType type). More... | |
typedef DataType | ValueType |
The template parameter value type. More... | |
Public Member Functions | |
Quaternion () | |
The default constructor. | |
Quaternion (DataType vr, DataType vi, DataType vj, DataType vk) | |
Constructor to initialize a quaternion with given component values. More... | |
Quaternion (const Vector< DataType > &v) | |
Constructor to initialize a quaternion from a given 4-vector containing a normalized rotation axis in its x,y and z components, and a rotation angle in its w component. More... | |
Quaternion (DataType angle, const Vector< DataType > &axis) | |
Constructor to initialize a quaternion from a given rotation angle and a normalized axis vector. More... | |
Quaternion (const Matrix< DataType > &m) | |
Constructor to initialize a quaternion from the rotation component of a given 4x4 matrix. More... | |
Quaternion (PredefinedType type) | |
Constructor to create a quaternion from a predefined type. More... | |
template<class DataType2 > | |
Quaternion (const Quaternion< DataType2 > &q) | |
The copy constructor using a quaternion of different type. More... | |
const DataType & | operator[] (UInt32 index) const |
Get a const reference to one of the 4 component values. More... | |
DataType & | operator[] (UInt32 index) |
Get a reference to one of the 4 component values. More... | |
const DataType * | GetPointer () const |
Get a const pointer to the raw data. More... | |
DataType * | GetPointer () |
Get a pointer to the raw data. More... | |
void | Set (const Matrix< DataType > &m) |
Set the quaternion from the rotation component of a given 4D matrix. More... | |
Quaternion & | operator= (const Vector< DataType > &v) |
Assignment operator to convert a 4D vector to a 4D quaternion. More... | |
Quaternion & | operator= (const Matrix< DataType > &m) |
Assignment operator to convert a 4D matrix to a 4D quaternion. More... | |
Quaternion & | operator+= (const Quaternion &q) |
In-place addition operator. More... | |
Quaternion & | operator*= (const Quaternion &q) |
In-place subtraction operator. More... | |
Quaternion & | operator*= (const Vector< DataType > &v) |
In-place quaternion-vector multiplication operator. More... | |
Quaternion & | operator*= (DataType d) |
In-place multiplication operator (scaling). More... | |
Quaternion | operator+ (const Quaternion &rhs) const |
Addition operator. More... | |
Quaternion | operator* (const Quaternion &rhs) const |
Quaternion-quaternion multiplication operator. More... | |
Quaternion | operator* (const Vector< DataType > &rhs) const |
Quaternion-vector multiplication operator. More... | |
Quaternion | operator* (DataType rhs) const |
Multiplication (scaling) operator. More... | |
void | Clear () |
Clear all components of the quaternion instance. More... | |
void | Set (const Quaternion &q) |
Copy the content of a source quaternion to the quaternion instance. More... | |
void | Set (DataType vr, DataType vi, DataType vj, DataType vk) |
Set all components of the quaternion instance to a set of given component values. More... | |
void | InvertSelf () |
In-place inversion. | |
void | AddSelf (const Quaternion &q) |
In-place addition. More... | |
void | MultiplySelf (const Quaternion &q) |
In-place Quaternion-quaternion multiplication. More... | |
void | MultiplySelf (const Vector< DataType > &v) |
In-place Quaternion-vector multiplication. More... | |
void | MultiplySelf (DataType d) |
In-place multiplication (scaling). More... | |
void | NormalizeSelf () |
In-place normalization of the quaternion instance. | |
Quaternion | Invert () const |
Get the inverse of a quaternion. More... | |
Quaternion | Add (const Quaternion &q) const |
Get the addition of a quaternion. More... | |
Quaternion | Multiply (const Quaternion &q) const |
Get the multiplication with a quaternion. More... | |
Quaternion | Multiply (const Vector< DataType > &v) const |
Get the multiplication with a vector. More... | |
Quaternion | Multiply (DataType d) const |
Get the multiplication (scaling). More... | |
Quaternion | Normalize () const |
Get the normalization of the quaternion instance. More... | |
Quaternion | Interpolate (const Quaternion &q, DataType t, Bool spherical) const |
Interpolate between this instance and a second quaternion. More... | |
Bool | IsEqual (const Quaternion &q) const |
Check if the quaternion instance is equal to a given second quaternion. More... | |
Bool | IsEqual (const Quaternion &q, DataType epsilon) const |
Check if the quaternion instance is equal to a given second quaternion. More... | |
String | ToString () const |
Get the string representation of the object. More... | |
SInt32 | GetCount () const |
Get the number of elements in the object. More... | |
Public Attributes | |
union { | |
DataType mComponents [NUM_COMPONENTS] | |
The components data array. More... | |
struct { | |
DataType r | |
The R component. More... | |
DataType i | |
The I component. More... | |
DataType j | |
The J component. More... | |
DataType k | |
The K component. More... | |
} | |
The components member struct. More... | |
}; | |
The components storage union overlaps the raw data array mComponents and the component structure. | |
Friends | |
bool | operator== (const Quaternion< DataType > &lhs, const Quaternion< DataType > &rhs) |
Equal to comparison operator. More... | |
bool | operator!= (const Quaternion< DataType > &lhs, const Quaternion< DataType > &rhs) |
Not equal to comparison operator. More... | |
typedef DataType Murl::Math::Quaternion< DataType >::ValueType |
The template parameter value type.
enum Murl::Math::Quaternion::Component |
enum Murl::Math::Quaternion::ComponentMask |
enum Murl::Math::Quaternion::PredefinedType |
Enumeration of the predefined initialization types for constructing a Quaternion(PredefinedType type).
Enumerator | |
---|---|
UNINITIALIZED | Create an uninitialized instance. |
IDENTITY | Initialize with the identity {1, 0, 0, 0}. |
|
inline |
Constructor to initialize a quaternion with given component values.
vr | The r component. |
vi | The i component. |
vj | The j component. |
vk | The k component. |
|
inline |
Constructor to initialize a quaternion from a given 4-vector containing a normalized rotation axis in its x,y and z components, and a rotation angle in its w component.
v | The vector. |
|
inline |
Constructor to initialize a quaternion from a given rotation angle and a normalized axis vector.
angle | The rotation angle. |
axis | The normalized axis vector. |
|
inline |
Constructor to initialize a quaternion from the rotation component of a given 4x4 matrix.
m | The matrix. |
|
inline |
Constructor to create a quaternion from a predefined type.
type | The predefined type. |
|
inline |
The copy constructor using a quaternion of different type.
q | The quaternion to copy. |
|
inline |
Get a const reference to one of the 4 component values.
index | The component index, see enum Component. |
|
inline |
Get a reference to one of the 4 component values.
index | The component index, see enum Component. |
|
inline |
Get a const pointer to the raw data.
|
inline |
Get a pointer to the raw data.
|
inline |
Set the quaternion from the rotation component of a given 4D matrix.
m | The input matrix. |
|
inline |
Assignment operator to convert a 4D vector to a 4D quaternion.
v | The vector to convert. |
|
inline |
Assignment operator to convert a 4D matrix to a 4D quaternion.
m | The matrix to convert. |
|
inline |
In-place addition operator.
q | The quaternion to add. |
|
inline |
In-place subtraction operator.
q | The quaternion to subtract. |
|
inline |
In-place quaternion-vector multiplication operator.
v | The vector to multiply. |
|
inline |
In-place multiplication operator (scaling).
d | The value to multiply. |
|
inline |
Addition operator.
rhs | The right hand side quaternion. |
|
inline |
Quaternion-quaternion multiplication operator.
rhs | The right hand side quaternion. |
|
inline |
Quaternion-vector multiplication operator.
rhs | The right hand side vector. |
|
inline |
Multiplication (scaling) operator.
rhs | The right hand side value. |
|
inline |
Clear all components of the quaternion instance.
Set all components to default constructor of data type.
|
inline |
Copy the content of a source quaternion to the quaternion instance.
q | The quaternion to copy from. |
|
inline |
Set all components of the quaternion instance to a set of given component values.
vr | The x-component value to set. |
vi | The y-component value to set. |
vj | The z-component value to set. |
vk | The w-component value to set. |
|
inline |
In-place addition.
q | The quaternion to add. |
|
inline |
In-place Quaternion-quaternion multiplication.
q | The quaternion to multiply. |
|
inline |
In-place Quaternion-vector multiplication.
v | The vector to multiply. |
|
inline |
In-place multiplication (scaling).
d | The value to multiply. |
|
inline |
Get the inverse of a quaternion.
This only works for normalized quaternions.
|
inline |
Get the addition of a quaternion.
q | The quaternion to add. |
|
inline |
Get the multiplication with a quaternion.
q | The quaternion to multiply. |
|
inline |
Get the multiplication with a vector.
v | The vector to multiply. |
|
inline |
Get the multiplication (scaling).
d | The value to multiply. |
|
inline |
Get the normalization of the quaternion instance.
|
inline |
Interpolate between this instance and a second quaternion.
For t=0.0, the result equals the first quaternion, and for t=1.0 the second one.
q | The quaternion to interpolate to. |
t | The interpolation factor. |
spherical | If true, a spherical interpolation is applied. If false, nterpolation is performed in a linear way. |
|
inline |
Check if the quaternion instance is equal to a given second quaternion.
Compares all values within the default epsilon range Limits::Epsilon().
q | The quaternion to compare. |
|
inline |
Check if the quaternion instance is equal to a given second quaternion.
Compares all values within a given epsilon range.
q | The quaternion to compare. |
epsilon | The epsilon to compare. |
|
inline |
Get the string representation of the object.
|
inline |
Get the number of elements in the object.
|
friend |
Equal to comparison operator.
Performs a test without an epsilon range, which can be used for detecting changes i.e. DoubleBuffer<Quaternion> class. To compare within an epsilon range use Quaternion::IsEqual().
lhs | The left hand side quaternion to compare. |
rhs | The right hand side quaternion to compare. |
|
friend |
Not equal to comparison operator.
Performs a test without an epsilon range, which can be used for detecting changes i.e. DoubleBuffer<Quaternion> class. To compare within an epsilon range use Quaternion::IsEqual().
lhs | The left hand side quaternion to compare. |
rhs | The right hand side quaternion to compare. |
DataType Murl::Math::Quaternion< DataType >::mComponents[NUM_COMPONENTS] |
The components data array.
DataType Murl::Math::Quaternion< DataType >::r |
The R component.
DataType Murl::Math::Quaternion< DataType >::i |
The I component.
DataType Murl::Math::Quaternion< DataType >::j |
The J component.
DataType Murl::Math::Quaternion< DataType >::k |
The K component.