SA_Maths
Sapphire Suite's C++ Maths Library
|
Quaternion Sapphire-Maths class. More...
#include <Quaternion.hpp>
Public Types | |
using | Type = T |
Type of the Quaternion. | |
Public Member Functions | |
Quat ()=default | |
Default constructor. | |
constexpr | Quat (T _w, T _x, T _y, T _z) noexcept |
Value constructor. | |
Quat (Quat &&)=default | |
Default move constructor. | |
Quat (const Quat &)=default | |
Default copy constructor. | |
template<typename TIn > | |
constexpr | Quat (const Quat< TIn > &_other) noexcept |
Value constructor from another quaternion type. | |
Quat (Deg< T > _angle, const Vec3< T > &_axis) noexcept | |
Value constructor angle and axis. | |
constexpr bool | IsZero () const noexcept |
Whether this quaternion is a zero quaternion. | |
constexpr bool | IsIdentity () const noexcept |
Whether this quaternion is an identity quaternion. | |
constexpr bool | Equals (const Quat &_other, T _threshold=std::numeric_limits< T >::epsilon()) const noexcept |
Compare 2 quaternion. | |
constexpr bool | operator== (const Quat< T > &_rhs) const noexcept |
Compare 2 quaternion equality. | |
constexpr bool | operator!= (const Quat< T > &_rhs) const noexcept |
Compare 2 quaternion inequality. | |
T * | Data () noexcept |
Getter of quaternion data | |
const T * | Data () const noexcept |
Const Getter of quaternion data | |
T & | operator[] (uint32_t _index) |
Access operator by index. | |
T | operator[] (uint32_t _index) const |
Const Access operator by index. | |
T | Length () const |
Getter of the length of this quaternion. | |
T | SqrLength () const noexcept |
Getter of the Squared Length of this quaternion. | |
Quat & | Normalize () |
Normalize this quaternion. | |
Quat | GetNormalized () const |
Normalize this quaternion. | |
bool | IsNormalized () const noexcept |
Whether this quaternion is normalized. | |
Quat & | Inverse () noexcept |
Inverse this quaternion. Quaternion should be normalized. | |
constexpr Quat | GetInversed () const noexcept |
Inverse this quaternion. Quaternion should be normalized. | |
Vec3< T > & | ImgAxis () noexcept |
Getter of quaternion's imaginary axis. | |
const Vec3< T > & | ImgAxis () const noexcept |
Const Getter of quaternion's imaginary axis. | |
constexpr Deg< T > | GetAngle () const noexcept |
Getter of the angle handled by this quaternion. | |
constexpr Vec3< T > | GetAxis () const noexcept |
Getter of the axis handled by this quaternion. | |
Quat< T > | Rotate (const Quat< T > &_other) const noexcept |
Rotate _other quaternion by this quaternion. | |
constexpr Vec3< T > | Rotate (const Vec3< T > &_vec) const noexcept |
Rotate _vec vector by this quaternion. | |
Quat< T > | UnRotate (const Quat< T > &_other) const noexcept |
Un-Rotate _other quaternion by this quaternion. | |
constexpr Vec3< T > | UnRotate (const Vec3< T > &_vec) const noexcept |
Un-Rotate _vec vector by this quaternion. | |
constexpr Vec3< T > | RightVector () const noexcept |
Getter of Right vector (X axis) rotated by this quaternion. | |
constexpr Vec3< T > | UpVector () const noexcept |
Getter of Up vector (Y axis) rotated by this quaternion. | |
constexpr Vec3< T > | ForwardVector () const noexcept |
Getter of Forward vector (Z axis) rotated by this quaternion. | |
Vec3< Deg< T > > | ToEuler () const noexcept |
Convert this quaternion into euler angles in degrees. | |
Quat & | operator= (Quat &&)=default |
Default assignment move operator. | |
Quat & | operator= (const Quat &)=default |
Default assignment copy operator. | |
constexpr Quat | operator- () const noexcept |
Getter of the opposite signed quaternion. | |
Quat | operator* (T _scale) const noexcept |
Scale each quaternion components by _scale. | |
Quat | operator/ (T _scale) const |
Inverse Scale each quaternion components by _scale. | |
Quat | operator+ (const Quat &_rhs) const noexcept |
Add term by term quaternion values. | |
Quat | operator- (const Quat &_rhs) const noexcept |
Subtract term by term quaternion values. | |
Quat | operator* (const Quat &_rhs) const noexcept |
Multiply quaternion to compute rotation. | |
constexpr Vec3< T > | operator* (const Vec3< T > &_rhs) const noexcept |
Rotate _rhs vector by this quaternion. | |
Quat | operator/ (const Quat &_rhs) const noexcept |
Divide quaternion to compute the inverse rotation. | |
constexpr Vec3< T > | operator/ (const Vec3< T > &_rhs) const noexcept |
Un-Rotate _rhs vector by this quaternion. | |
constexpr T | operator| (const Quat &_rhs) const noexcept |
Compute the Dot product between this and _rhs. | |
Quat & | operator*= (T _scale) noexcept |
Scale each quaternion values by _scale. | |
Quat & | operator/= (T _scale) |
Inverse Scale each quaternion values by _scale. | |
Quat & | operator+= (const Quat &_rhs) noexcept |
Add term by term quaternion values. | |
Quat & | operator-= (const Quat &_rhs) noexcept |
Substract term by term quaternion values. | |
Quat & | operator*= (const Quat &_rhs) noexcept |
Multiply quaternion to compute rotation. | |
Quat & | operator/= (const Quat &_rhs) noexcept |
Divide quaternion to compute the inverse rotation. | |
Static Public Member Functions | |
static Quat | FromEuler (const Vec3< Deg< T > > &_angles) noexcept |
Create quaternion from euler angles in degrees. | |
static T | Dot (const Quat &_lhs, const Quat &_rhs) noexcept |
Compute the Dot product between _lhs and _rhs. | |
static Quat | Lerp (const Quat &_start, const Quat &_end, float _alpha) |
Clamped Lerp from _start to _end at _alpha. | |
static Quat | LerpUnclamped (const Quat &_start, const Quat &_end, float _alpha) |
Unclamped Lerp from _start to _end at _alpha. | |
static Quat | SLerp (const Quat &_start, const Quat &_end, float _alpha) |
Clamped SLerp from _start to _end at _alpha. | |
static Quat | SLerpUnclamped (const Quat &_start, const Quat &_end, float _alpha) |
Unclamped SLerp from _start to _end at _alpha. | |
Static Public Attributes | |
static const Quat | Zero |
Zero quaternion constant { 0, 0, 0, 0 }. | |
static const Quat | Identity |
Identity quaternion constant { 1, 0, 0, 0 }. | |
Quaternion Sapphire-Maths class.
must be align at 4 * sizeof(T) for intrinsics. For T = float: align as 16. For T = double: align as 32.
T | Type of the Quaternion. |
|
constexprnoexcept |
Value constructor.
[in] | _w | W value. |
[in] | _x | X value. |
[in] | _y | Y value. |
[in] | _z | Z value. |
|
constexprnoexcept |
Value constructor from another quaternion type.
TIn | Type of the input quaternion. |
[in] | _other | Quat to construct from. |
Value constructor angle and axis.
[in] | _angle | Angle rotation in Degree. |
[in] | _axis | Axis rotation. |
|
noexcept |
Const Getter of quaternion data
|
noexcept |
Getter of quaternion data
|
staticnoexcept |
Compute the Dot product between _lhs and _rhs.
[in] | _lhs | Left hand side operand to compute dot product with. |
[in] | _rhs | Right hand side operand to compute dot product with. |
|
constexprnoexcept |
Compare 2 quaternion.
[in] | _other | Other quaternion to compare to. |
[in] | _threshold | Allowed threshold to accept equality. |
Getter of Forward vector (Z axis) rotated by this quaternion.
|
staticnoexcept |
Create quaternion from euler angles in degrees.
[in] | _angles | Euler angles in degree (using Engine euler norm). |
Euler norm: X-Axis: Pitch Y-Axis: Yaw Z-Axis: Roll
Getter of the angle handled by this quaternion.
Getter of the axis handled by this quaternion.
Inverse this quaternion. Quaternion should be normalized.
Normalize this quaternion.
Const Getter of quaternion's imaginary axis.
Get the values of i, j and k axis (x, y, z).
Getter of quaternion's imaginary axis.
Get the values of i, j and k axis (x, y, z).
Inverse this quaternion. Quaternion should be normalized.
|
constexprnoexcept |
Whether this quaternion is an identity quaternion.
|
noexcept |
Whether this quaternion is normalized.
|
constexprnoexcept |
Whether this quaternion is a zero quaternion.
T SA::Quat< T >::Length | ( | ) | const |
Getter of the length of this quaternion.
|
static |
Clamped Lerp from _start to _end at _alpha.
_start and _end should be normalized. Result quaternion is normalized. Reference: https://en.wikipedia.org/wiki/Linear_interpolation
_start | Starting point of the lerp. |
_end | Ending point of the lerp. |
_alpha | Alpha of the lerp. |
|
static |
Unclamped Lerp from _start to _end at _alpha.
_start and _end should be normalized. Result quaternion is normalized. Reference: https://en.wikipedia.org/wiki/Linear_interpolation
_start | Starting point of the lerp. |
_end | Ending point of the lerp. |
_alpha | Alpha of the lerp. |
Normalize this quaternion.
|
constexprnoexcept |
Compare 2 quaternion inequality.
[in] | _rhs | Other quaternion to compare to. |
Multiply quaternion to compute rotation.
Rotate _rhs by this (ie: this.Rotate(_rhs)). Quaternion should be normalized.
[in] | _rhs | Quaternion to multiply. |
|
constexprnoexcept |
Rotate _rhs vector by this quaternion.
Apply quaternion rotation to vector. Quaternion must be normalized.
[in] | _rhs | Vector to rotate. |
Scale each quaternion components by _scale.
[in] | _scale | Scale value to apply on components. |
Multiply quaternion to compute rotation.
Quaternion should be normalized.
[in] | _rhs | Quaternion to multiply. |
Scale each quaternion values by _scale.
TIn | Type of the input scale. |
[in] | _scale | Scale value to apply on all components. |
Add term by term quaternion values.
[in] | _rhs | Quaternion to add. |
Add term by term quaternion values.
[in] | _rhs | Quaternion to add. |
Getter of the opposite signed quaternion.
Subtract term by term quaternion values.
[in] | _rhs | Quaternion to substract. |
Substract term by term quaternion values.
[in] | _rhs | Quaternion to substract. |
Divide quaternion to compute the inverse rotation.
Unrotate _rhs by this (ie: this.UnRotate(_rhs)). Quaternion should be normalized.
[in] | _rhs | Quaternion to divide. |
|
constexprnoexcept |
Un-Rotate _rhs vector by this quaternion.
Apply quaternion inverse rotation to vector. Quaternion must be normalized.
[in] | _rhs | Vector to un-rotate. |
Inverse Scale each quaternion components by _scale.
[in] | _scale | Inverse scale value to apply on all components. |
Divide quaternion to compute the inverse rotation.
Quaternion should be normalized.
[in] | _rhs | Quaternion to divide. |
Inverse Scale each quaternion values by _scale.
TIn | Type of the input scale. |
[in] | _scale | Scale value to apply on all components. |
Default assignment copy operator.
Default assignment move operator.
|
constexprnoexcept |
Compare 2 quaternion equality.
[in] | _rhs | Other quaternion to compare to. |
T & SA::Quat< T >::operator[] | ( | uint32_t | _index | ) |
Access operator by index.
[in] | _index | Index to access: 0 == w, 1 == x, 2 == y, 3 == z. |
T SA::Quat< T >::operator[] | ( | uint32_t | _index | ) | const |
Const Access operator by index.
[in] | _index | Index to access: 0 == w, 1 == x, 2 == y, 3 == z. |
|
constexprnoexcept |
Compute the Dot product between this and _rhs.
[in] | _rhs | Right hand side operand quaternion to compute dot product with. |
Getter of Right vector (X axis) rotated by this quaternion.
Rotate _other quaternion by this quaternion.
Multiply two quaternions. Quaternion must be normalized.
[in] | _other | Quaternion to rotate. |
|
constexprnoexcept |
Rotate _vec vector by this quaternion.
Apply quaternion rotation to vector. Quaternion must be normalized.
[in] | _vec | Vector to rotate. |
|
static |
Clamped SLerp from _start to _end at _alpha.
_start and _end should be normalized. Result quaternion is normalized. Reference: https://en.wikipedia.org/wiki/Slerp
_start | Starting point of the lerp. |
_end | Ending point of the lerp. |
_alpha | Alpha of the lerp. |
|
static |
Unclamped SLerp from _start to _end at _alpha.
_start and _end should be normalized. Result quaternion is normalized. Reference: https://en.wikipedia.org/wiki/Slerp
_start | Starting point of the lerp. |
_end | Ending point of the lerp. |
_alpha | Alpha of the lerp. |
|
noexcept |
Getter of the Squared Length of this quaternion.
Convert this quaternion into euler angles in degrees.
Euler norm: X-Axis: Pitch Y-Axis: Yaw Z-Axis: Roll
Un-Rotate _other quaternion by this quaternion.
Apply the inverse rotation multiplication. Quaternion must be normalized.
[in] | _other | Quaternion to un-rotate. |
|
constexprnoexcept |
Un-Rotate _vec vector by this quaternion.
Apply the inverse rotation to vector. Quaternion must be normalized.
[in] | _vec | Vector to un-rotate. |
Getter of Up vector (Y axis) rotated by this quaternion.