Jet
v1.3.3
|
Quaternion class defined as q = w + xi + yj + zk. More...
#include <jet/quaternion.h>
Public Member Functions | |
Quaternion () | |
Make an identity quaternion. More... | |
Quaternion (T newW, T newX, T newY, T newZ) | |
Constructs a quaternion with given elements. More... | |
Quaternion (const std::initializer_list< T > &lst) | |
Constructs a quaternion with given elements. More... | |
Quaternion (const Vector3< T > &axis, T angle) | |
Constructs a quaternion with given rotation axis and angle. More... | |
Quaternion (const Vector3< T > &from, const Vector3< T > &to) | |
Constructs a quaternion with from and to vectors. More... | |
Quaternion (const Vector3< T > &axis0, const Vector3< T > &axis1, const Vector3< T > &axis2) | |
Constructs a quaternion with three basis vectors. More... | |
Quaternion (const Matrix3x3< T > &m33) | |
Constructs a quaternion with 3x3 rotational matrix. More... | |
Quaternion (const Quaternion &other) | |
Copy constructor. More... | |
void | set (const Quaternion &other) |
Sets the quaternion with other quaternion. More... | |
void | set (T newW, T newX, T newY, T newZ) |
Sets the quaternion with given elements. More... | |
void | set (const std::initializer_list< T > &lst) |
Sets the quaternion with given elements. More... | |
void | set (const Vector3< T > &axis, T angle) |
Sets the quaternion with given rotation axis and angle. More... | |
void | set (const Vector3< T > &from, const Vector3< T > &to) |
Sets the quaternion with from and to vectors. More... | |
void | set (const Vector3< T > &rotationBasis0, const Vector3< T > &rotationBasis1, const Vector3< T > &rotationBasis2) |
Sets quaternion with three basis vectors. More... | |
void | set (const Matrix3x3< T > &matrix) |
Sets the quaternion with 3x3 rotational matrix. More... | |
template<typename U > | |
Quaternion< U > | castTo () const |
Returns quaternion with other base type. More... | |
Quaternion | normalized () const |
Returns normalized quaternion. More... | |
Vector3< T > | mul (const Vector3< T > &v) const |
Returns this quaternion * vector. More... | |
Quaternion | mul (const Quaternion &other) const |
Returns this quaternion * other quaternion. More... | |
T | dot (const Quaternion< T > &other) |
Computes the dot product with other quaternion. More... | |
Quaternion | rmul (const Quaternion &other) const |
Returns other quaternion * this quaternion. More... | |
void | imul (const Quaternion &other) |
Returns this quaternion *= other quaternion. More... | |
void | setIdentity () |
Makes this quaternion identity. More... | |
void | rotate (T angleInRadians) |
Rotate this quaternion with given angle in radians. More... | |
void | normalize () |
Normalizes the quaternion. More... | |
Vector3< T > | axis () const |
Returns the rotational axis. More... | |
T | angle () const |
Returns the rotational angle. More... | |
void | getAxisAngle (Vector3< T > *axis, T *angle) const |
Returns the axis and angle. More... | |
Quaternion | inverse () const |
Returns the inverse quaternion. More... | |
Matrix3x3< T > | matrix3 () const |
Converts to the 3x3 rotation matrix. More... | |
Matrix4x4< T > | matrix4 () const |
Converts to the 4x4 rotation matrix. More... | |
T | l2Norm () const |
Returns L2 norm of this quaternion. More... | |
Quaternion & | operator= (const Quaternion &other) |
Assigns other quaternion. More... | |
Quaternion & | operator*= (const Quaternion &other) |
Returns this quaternion *= other quaternion. More... | |
T & | operator[] (size_t i) |
Returns the reference to the i-th element. More... | |
const T & | operator[] (size_t i) const |
Returns the const reference to the i-th element. More... | |
bool | operator== (const Quaternion &other) const |
Returns true if equal. More... | |
bool | operator!= (const Quaternion &other) const |
Returns true if not equal. More... | |
Static Public Member Functions | |
static Quaternion | makeIdentity () |
Returns identity matrix. More... | |
Public Attributes | |
T | w |
Real part. More... | |
T | x |
Imaginary part (j). More... | |
T | y |
Imaginary part (k). More... | |
T | z |
Quaternion class defined as q = w + xi + yj + zk.
jet::Quaternion< T >::Quaternion | ( | ) |
Make an identity quaternion.
jet::Quaternion< T >::Quaternion | ( | T | newW, |
T | newX, | ||
T | newY, | ||
T | newZ | ||
) |
Constructs a quaternion with given elements.
jet::Quaternion< T >::Quaternion | ( | const std::initializer_list< T > & | lst | ) |
Constructs a quaternion with given elements.
jet::Quaternion< T >::Quaternion | ( | const Vector3< T > & | axis, |
T | angle | ||
) |
Constructs a quaternion with given rotation axis and angle.
jet::Quaternion< T >::Quaternion | ( | const Vector3< T > & | from, |
const Vector3< T > & | to | ||
) |
Constructs a quaternion with from and to vectors.
jet::Quaternion< T >::Quaternion | ( | const Vector3< T > & | axis0, |
const Vector3< T > & | axis1, | ||
const Vector3< T > & | axis2 | ||
) |
Constructs a quaternion with three basis vectors.
|
explicit |
Constructs a quaternion with 3x3 rotational matrix.
jet::Quaternion< T >::Quaternion | ( | const Quaternion< T > & | other | ) |
Copy constructor.
T jet::Quaternion< T >::angle | ( | ) | const |
Returns the rotational angle.
Vector3<T> jet::Quaternion< T >::axis | ( | ) | const |
Returns the rotational axis.
Returns quaternion with other base type.
T jet::Quaternion< T >::dot | ( | const Quaternion< T > & | other | ) |
Computes the dot product with other quaternion.
void jet::Quaternion< T >::getAxisAngle | ( | Vector3< T > * | axis, |
T * | angle | ||
) | const |
Returns the axis and angle.
void jet::Quaternion< T >::imul | ( | const Quaternion< T > & | other | ) |
Returns this quaternion *= other quaternion.
Quaternion jet::Quaternion< T >::inverse | ( | ) | const |
Returns the inverse quaternion.
T jet::Quaternion< T >::l2Norm | ( | ) | const |
Returns L2 norm of this quaternion.
|
static |
Returns identity matrix.
Matrix3x3<T> jet::Quaternion< T >::matrix3 | ( | ) | const |
Converts to the 3x3 rotation matrix.
Matrix4x4<T> jet::Quaternion< T >::matrix4 | ( | ) | const |
Converts to the 4x4 rotation matrix.
Quaternion jet::Quaternion< T >::mul | ( | const Quaternion< T > & | other | ) | const |
Returns this quaternion * other quaternion.
Vector3<T> jet::Quaternion< T >::mul | ( | const Vector3< T > & | v | ) | const |
Returns this quaternion * vector.
void jet::Quaternion< T >::normalize | ( | ) |
Normalizes the quaternion.
Quaternion jet::Quaternion< T >::normalized | ( | ) | const |
Returns normalized quaternion.
bool jet::Quaternion< T >::operator!= | ( | const Quaternion< T > & | other | ) | const |
Returns true if not equal.
Quaternion& jet::Quaternion< T >::operator*= | ( | const Quaternion< T > & | other | ) |
Returns this quaternion *= other quaternion.
Quaternion& jet::Quaternion< T >::operator= | ( | const Quaternion< T > & | other | ) |
Assigns other quaternion.
bool jet::Quaternion< T >::operator== | ( | const Quaternion< T > & | other | ) | const |
Returns true if equal.
T& jet::Quaternion< T >::operator[] | ( | size_t | i | ) |
Returns the reference to the i-th element.
const T& jet::Quaternion< T >::operator[] | ( | size_t | i | ) | const |
Returns the const reference to the i-th element.
Quaternion jet::Quaternion< T >::rmul | ( | const Quaternion< T > & | other | ) | const |
Returns other quaternion * this quaternion.
void jet::Quaternion< T >::rotate | ( | T | angleInRadians | ) |
Rotate this quaternion with given angle in radians.
void jet::Quaternion< T >::set | ( | const Matrix3x3< T > & | matrix | ) |
Sets the quaternion with 3x3 rotational matrix.
void jet::Quaternion< T >::set | ( | const Quaternion< T > & | other | ) |
Sets the quaternion with other quaternion.
void jet::Quaternion< T >::set | ( | const std::initializer_list< T > & | lst | ) |
Sets the quaternion with given elements.
void jet::Quaternion< T >::set | ( | const Vector3< T > & | axis, |
T | angle | ||
) |
Sets the quaternion with given rotation axis and angle.
void jet::Quaternion< T >::set | ( | const Vector3< T > & | from, |
const Vector3< T > & | to | ||
) |
Sets the quaternion with from and to vectors.
void jet::Quaternion< T >::set | ( | const Vector3< T > & | rotationBasis0, |
const Vector3< T > & | rotationBasis1, | ||
const Vector3< T > & | rotationBasis2 | ||
) |
Sets quaternion with three basis vectors.
void jet::Quaternion< T >::set | ( | T | newW, |
T | newX, | ||
T | newY, | ||
T | newZ | ||
) |
Sets the quaternion with given elements.
void jet::Quaternion< T >::setIdentity | ( | ) |
Makes this quaternion identity.
T jet::Quaternion< T >::w |
Real part.
Imaginary part (i).
T jet::Quaternion< T >::x |
Imaginary part (j).
T jet::Quaternion< T >::y |
Imaginary part (k).
T jet::Quaternion< T >::z |