A quaternion, symbolizing rotations as a 4D vector. More...
Public Member Functions | |
Quaternion () noexcept | |
Quaternion (float x, float y, float z, float w) noexcept | |
Quaternion (const Vector &axis, float angle) noexcept | |
Quaternion (const Vector &eulerAngles) noexcept | |
Quaternion (const Matrix &mat) noexcept | |
Quaternion (const Quaternion &other) noexcept | |
Vector | getAsEulerAngles () const |
Vector | getAsAxisAngle () const |
Quaternion & | setFromAxisAngle (const Vector &axis, float angle) |
Quaternion & | setFromEuler (const Vector &angles) |
Quaternion & | setFromOrientationMatrix (const Matrix &mat) |
Quaternion & | setFromTransformationMatrix (const Matrix &mat) |
Vector | transform (const Vector &vector) const |
Vector & | apply (Vector &vector) const |
nkMemory::String | toString () const |
Quaternion & | fromString (nkMemory::StringView str) |
Quaternion & | operator= (const Quaternion &other) noexcept |
Vector | operator* (const Vector &other) const |
Quaternion | operator* (const Quaternion &other) const |
void | operator*= (const Quaternion &other) |
bool | operator== (const Quaternion &other) const |
Public Attributes | |
float | _x |
X component of the quaternion. | |
float | _y |
Y component of the quaternion. | |
float | _z |
Z component of the quaternion. | |
float | _w |
W component of the quaternion. | |
A quaternion, symbolizing rotations as a 4D vector.
The equation for the quaternion is considered as : xi + yj + zk + w.
|
noexcept |
Default constructor. Defaults to (0, 0, 0, 1), encoding no rotation.
|
noexcept |
Filling constructor.
x | The x component. |
y | The y component. |
z | The z component. |
w | The w component. |
|
noexcept |
Axis angle constructor.
axis | The axis of rotation to consider. |
angle | The angle around this axis, in radians. |
|
noexcept |
Euler angles constructor.
eulerAngles | The euler angles, considering rotation in ZYX (Yaw-Pitch-Roll) order. |
|
noexcept |
Matrix constructor.
mat | The matrix from which to extract the rotation. |
|
noexcept |
Copy constructor.
other | The quaternion to copy. |
Vector nkMaths::Quaternion::getAsEulerAngles | ( | ) | const |
Vector nkMaths::Quaternion::getAsAxisAngle | ( | ) | const |
Quaternion& nkMaths::Quaternion::setFromAxisAngle | ( | const Vector & | axis, |
float | angle | ||
) |
Sets the quaternion from an axis and angle pair.
axis | The axis to rotate around. |
angle | The angle to rotate, in radians. |
Quaternion& nkMaths::Quaternion::setFromEuler | ( | const Vector & | angles | ) |
Sets the quaternion from euler angles.
angles | The euler angles to translate, considering rotation in ZYX (Yaw-Pitch-Roll) order. |
Quaternion& nkMaths::Quaternion::setFromOrientationMatrix | ( | const Matrix & | mat | ) |
Sets the quaternion from a rotation matrix.
mat | The matrix to extract the rotation from. |
Quaternion& nkMaths::Quaternion::setFromTransformationMatrix | ( | const Matrix & | mat | ) |
Sets the quaternion from a full transformation matrix.
mat | The matrix to extract the rotation from. |
Rotates a vector, by copying it and returning it. Another way to express q * v.
vector | The vector to rotate. |
Rotates a vector, by altering the vector parameter. Another way to express q *= v.
vector | The vector to rotate. |
nkMemory::String nkMaths::Quaternion::toString | ( | ) | const |
Quaternion& nkMaths::Quaternion::fromString | ( | nkMemory::StringView | str | ) |
Parse components from a string. Format is "x,y,z,w".
str | The string to parse. |
|
noexcept |
Assignment operator.
other | The quaternion to assign. |
Multiplication operator.
other | The vector to apply the quaternion to. |
Quaternion nkMaths::Quaternion::operator* | ( | const Quaternion & | other | ) | const |
Multiplication operator.
other | The quaternion to multiply with. |
void nkMaths::Quaternion::operator*= | ( | const Quaternion & | other | ) |
Multiplication and assignment operator.
other | The quaternion to multiply with. |
bool nkMaths::Quaternion::operator== | ( | const Quaternion & | other | ) | const |
Comparison operator.
other | The quaternion to compare with. |