5#ifndef SAPPHIRE_MATHS_QUATERNION_GUARD
6#define SAPPHIRE_MATHS_QUATERNION_GUARD
21#if SA_MATHS_QUATERNION_SIMD
23 #include <SA/Support/Intrinsics.hpp>
52 struct alignas(sizeof(T) * 4)
Quat
93 constexpr Quat(T _w, T _x, T _y, T _z)
noexcept;
109 template <
typename TIn>
147 constexpr
bool Equals(const
Quat& _other, T _threshold = std::numeric_limits<T>::epsilon()) const noexcept;
157 constexpr
bool operator==(const
Quat<T>& _rhs) const noexcept;
166 constexpr
bool operator!=(const
Quat<T>& _rhs) const noexcept;
184 const T*
Data() const noexcept;
194 T& operator[](uint32_t _index);
203 T operator[](uint32_t _index) const;
506 constexpr
Quat operator-() const noexcept;
515 Quat operator*(T _scale) const noexcept;
524 Quat operator/(T _scale) const;
566 constexpr
Vec3<T> operator*(const
Vec3<T>& _rhs) const noexcept;
590 constexpr
Vec3<T> operator/(const
Vec3<T>& _rhs) const noexcept;
599 constexpr T operator|(const
Quat& _rhs) const noexcept;
609 Quat& operator*=(T _scale) noexcept;
673 std::string ToString() const noexcept;
687 template <
typename T>
698 template <
typename T>
712 template <
typename T>
726 template <
typename T>
743 template <
typename T>
744 std::string ToString(
const Quat<T>& _q);
759 template <
typename T>
774#if SA_MATHS_QUATERNION_SIMD && SA_INTRISC_SSE
801 Quatf Quatf::operator*(
float _scale) const noexcept;
814 Quatf&
Quatf::operator*=(
float _scale) noexcept;
827 Quatf operator/(
float _lhs, const
Quatf& _rhs);
831#if SA_MATHS_QUATERNION_SIMD && SA_INTRISC_AVX
859 Quatd Quatd::operator*(
double _scale) const noexcept;
872 Quatd&
Quatd::operator*=(
double _scale) noexcept;
885 Quatd operator/(
double _lhs, const
Quatd& _rhs);
900#include <SA/Maths/Space/Quaternion.inl>
Maths specific config file.
Cosinus method implementation.
Maths module Debug compatibility definition.
Degree type implementation.
Equals method implementation.
Lerp algorithms implementation.
Mat3< T, major > operator*(TIn _lhs, const Mat3< T, major > &_rhs) noexcept
Scale each matrix components by _lhs.
Mat3< T, major > operator/(TIn _lhs, const Mat3< T, major > &_rhs)
Inverse Scale each matrix components by _lhs.
Sinus method implementation.
Square Root algorithm implementation.
Tangent method implementation.
Maths Degree type.
Definition Degree.hpp:37
Quaternion Sapphire-Maths class.
Definition Quaternion.hpp:53
constexpr Quat GetInversed() const noexcept
Inverse this quaternion. Quaternion should be normalized.
Quat(Deg< T > _angle, const Vec3< T > &_axis) noexcept
Value constructor angle and axis.
constexpr Vec3< T > UpVector() const noexcept
Getter of Up vector (Y axis) rotated by this quaternion.
constexpr bool IsZero() const noexcept
Whether this quaternion is a zero quaternion.
static Quat SLerpUnclamped(const Quat &_start, const Quat &_end, float _alpha)
Unclamped SLerp from _start to _end at _alpha.
Vec3< Deg< T > > ToEuler() const noexcept
Convert this quaternion into euler angles in degrees.
Quat & Inverse() noexcept
Inverse this quaternion. Quaternion should be normalized.
static Quat LerpUnclamped(const Quat &_start, const Quat &_end, float _alpha)
Unclamped Lerp from _start to _end at _alpha.
constexpr Vec3< T > ForwardVector() const noexcept
Getter of Forward vector (Z axis) rotated by this quaternion.
Quat< T > UnRotate(const Quat< T > &_other) const noexcept
Un-Rotate _other quaternion by this quaternion.
Quat(Quat &&)=default
Default move constructor.
Quat & Normalize()
Normalize this quaternion.
T * Data() noexcept
Getter of quaternion data
constexpr bool Equals(const Quat &_other, T _threshold=std::numeric_limits< T >::epsilon()) const noexcept
Compare 2 quaternion.
constexpr Quat(T _w, T _x, T _y, T _z) noexcept
Value constructor.
static Quat SLerp(const Quat &_start, const Quat &_end, float _alpha)
Clamped SLerp from _start to _end at _alpha.
static Quat FromEuler(const Vec3< Deg< T > > &_angles) noexcept
Create quaternion from euler angles in degrees.
constexpr bool IsIdentity() const noexcept
Whether this quaternion is an identity quaternion.
T SqrLength() const noexcept
Getter of the Squared Length of this quaternion.
static const Quat Identity
Identity quaternion constant { 1, 0, 0, 0 }.
Definition Quaternion.hpp:76
T y
Quaternion's Y component (j axis).
Definition Quaternion.hpp:65
static T Dot(const Quat &_lhs, const Quat &_rhs) noexcept
Compute the Dot product between _lhs and _rhs.
T w
Quaternion's W component (Real value).
Definition Quaternion.hpp:59
constexpr Vec3< T > RightVector() const noexcept
Getter of Right vector (X axis) rotated by this quaternion.
T Length() const
Getter of the length of this quaternion.
T Type
Type of the Quaternion.
Definition Quaternion.hpp:55
static Quat Lerp(const Quat &_start, const Quat &_end, float _alpha)
Clamped Lerp from _start to _end at _alpha.
Quat< T > Rotate(const Quat< T > &_other) const noexcept
Rotate _other quaternion by this quaternion.
constexpr Deg< T > GetAngle() const noexcept
Getter of the angle handled by this quaternion.
static const Quat Zero
Zero quaternion constant { 0, 0, 0, 0 }.
Definition Quaternion.hpp:73
T x
Quaternion's X component (i axis).
Definition Quaternion.hpp:62
Vec3< T > & ImgAxis() noexcept
Getter of quaternion's imaginary axis.
bool IsNormalized() const noexcept
Whether this quaternion is normalized.
Quat()=default
Default constructor.
constexpr Quat(const Quat< TIn > &_other) noexcept
Value constructor from another quaternion type.
Quat(const Quat &)=default
Default copy constructor.
T z
Quaternion's Z component (k axis).
Definition Quaternion.hpp:68
constexpr Vec3< T > GetAxis() const noexcept
Getter of the axis handled by this quaternion.
Quat GetNormalized() const
Normalize this quaternion.
Vector 3 Sapphire-Maths class.
Definition Vector3.hpp:43