5#ifndef SAPPHIRE_MATHS_MATRIX4_GUARD
6#define SAPPHIRE_MATHS_MATRIX4_GUARD
13#include <SA/Maths/Matrix/Matrix4Base.hpp>
18#if SA_MATHS_MATRIX4_SIMD
20 #include <SA/Support/Intrinsics.hpp>
45 template <
typename T, MatrixMajor major>
57#if SA_MATHS_MATRIX4_SIMD && SA_INTRISC
59 template <
typename T, MatrixMajor major = MatrixMajor::Default>
60 struct alignas(32) Mat4 :
public Intl::Mat4_Base<T, major>
64 template <typename T, MatrixMajor major = MatrixMajor::Default>
65 struct
Mat4 :
public Intl::Mat4_Base<T, major>
69 using Intl::Mat4_Base<T, major>::e00;
70 using Intl::Mat4_Base<T, major>::e01;
71 using Intl::Mat4_Base<T, major>::e02;
72 using Intl::Mat4_Base<T, major>::e03;
74 using Intl::Mat4_Base<T, major>::e10;
75 using Intl::Mat4_Base<T, major>::e11;
76 using Intl::Mat4_Base<T, major>::e12;
77 using Intl::Mat4_Base<T, major>::e13;
79 using Intl::Mat4_Base<T, major>::e20;
80 using Intl::Mat4_Base<T, major>::e21;
81 using Intl::Mat4_Base<T, major>::e22;
82 using Intl::Mat4_Base<T, major>::e23;
84 using Intl::Mat4_Base<T, major>::e30;
85 using Intl::Mat4_Base<T, major>::e31;
86 using Intl::Mat4_Base<T, major>::e32;
87 using Intl::Mat4_Base<T, major>::e33;
115 using Intl::Mat4_Base<T, major>::Mat4_Base;
125 template <
typename TIn, MatrixMajor majorIn>
136 template <
typename TIn, MatrixMajor majorIn>
164 constexpr
bool Equals(const
Mat4& _other, T _threshold = std::numeric_limits<T>::epsilon()) const noexcept;
174 constexpr
bool operator==(const
Mat4& _rhs) const noexcept;
183 constexpr
bool operator!=(const
Mat4& _rhs) const noexcept;
201 const T*
Data() const noexcept;
211 T&
At(uint32_t _index);
220 const T&
At(uint32_t _index) const;
230 T&
At(uint32_t _x, uint32_t _y);
240 const T&
At(uint32_t _x, uint32_t _y) const;
250 T& operator[](uint32_t _index);
259 const T& operator[](uint32_t _index) const;
409 static
Mat4 MakePerspective(T _fov = T(90.0), T _aspect = T(1.0), T _near = T(0.35), T _far = T(10.0)) noexcept;
424 Mat4& operator=(const
Mat4<TIn, majorIn> _rhs) noexcept;
431 constexpr
Mat4 operator-() const noexcept;
441 template<typename TIn>
442 Mat4 operator*(TIn _scale) const noexcept;
452 template<typename TIn>
453 Mat4 operator/(TIn _scale) const;
501 Vec3<T> operator*(const
Vec3<T>&_rhs) const noexcept;
510 Vec4<T> operator*(const
Vec4<T>&_rhs) const noexcept;
521 template<typename TIn>
522 Mat4& operator*=(TIn _scale) noexcept;
532 template<typename TIn>
584 std::string ToString() const noexcept;
589#if SA_MATHS_MATRIX4_SIMD && SA_INTRISC
607 template <
typename TIn,
typename T, MatrixMajor major>
620 template <
typename TIn,
typename T, MatrixMajor major>
638 template <
typename T, MatrixMajor major>
657 template <
typename T, MatrixMajor major = MatrixMajor::Default>
693#if SA_MATHS_MATRIX4_SIMD && SA_INTRISC_AVX
791#if SA_MATHS_MATRIX4_SIMD && SA_INTRISC_SSE
825 Vec3<
float>
RMat4f::operator*(const
Vec3<
float>& _rhs) const noexcept;
828 Vec4<
float>
RMat4f::operator*(const
Vec4<
float>& _rhs) const noexcept;
854 float CMat4f::Determinant() const noexcept;
883 Vec3<
float>
CMat4f::operator*(const
Vec3<
float>& _rhs) const noexcept;
886 Vec4<
float>
CMat4f::operator*(const
Vec4<
float>& _rhs) const noexcept;
911#if SA_MATHS_MATRIX4_SIMD && SA_INTRISC_AVX
945 Vec3<
double>
RMat4d::operator*(const
Vec3<
double>& _rhs) const noexcept;
948 Vec4<
double>
RMat4d::operator*(const
Vec4<
double>& _rhs) const noexcept;
974 double CMat4d::Determinant() const noexcept;
1003 Vec3<
double>
CMat4d::operator*(const
Vec3<
double>& _rhs) const noexcept;
1006 Vec4<
double>
CMat4d::operator*(const
Vec4<
double>& _rhs) const noexcept;
1042#include <SA/Maths/Matrix/Matrix4.inl>
Maths specific config file.
Maths module Debug compatibility definition.
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.
MatrixMajor
Matrix major enum.
Definition MatrixMajor.hpp:24
Matrix 3x3 Sapphire-Maths class.
Definition Matrix3.hpp:69
Matrix 4x4 Sapphire-Maths class.
Definition Matrix4.hpp:68
static Mat4 MakeRotation(const Quat< T > &_rot) noexcept
Make rotation matrix from quaternion.
Mat4 & operator*=(TIn _scale) noexcept
Scale each matrix component by _scale.
Mat4 & Inverse()
Inverse this matrix.
static Mat4 MakeLookAt(const Vec3< T > &_eye, const Vec3< T > &_target, const Vec3< T > &_up)
Make LookAt matrix from center, target and up.
constexpr Mat4 operator-() const noexcept
Getter of the opposite signed matrix.
T * Data() noexcept
Getter of matrix data
Mat4 & operator+=(const Mat4 &_rhs) noexcept
Add term by term matrix values.
constexpr Mat4 GetTransposed() const noexcept
Transpose this matrix.
constexpr Mat4(const Mat4< TIn, majorIn > &_other) noexcept
Value constructor from another Mat4 type.
static Mat4 MakePerspective(T _fov=T(90.0), T _aspect=T(1.0), T _near=T(0.35), T _far=T(10.0)) noexcept
Make perspective matrix .
constexpr bool Equals(const Mat4 &_other, T _threshold=std::numeric_limits< T >::epsilon()) const noexcept
Compare 2 Matrix.
Mat4 & operator-=(const Mat4 &_rhs) noexcept
Subtract term by term matrix values.
Mat4 & Transpose() noexcept
Transpose this matrix.
Mat4 operator/(TIn _scale) const
Inverse Scale each matrix component by _scale.
static const Mat4 Identity
Identity Mat4 constant.
Definition Matrix4.hpp:109
constexpr bool IsZero() const noexcept
Whether this matrix is a zero matrix.
T & At(uint32_t _index)
Getter of Value at index.
static Mat4 MakeTranslation(const Vec3< T > &_transl) noexcept
Make translation matrix from vector3.
Mat4 operator*(TIn _scale) const noexcept
Scale each matrix component by _scale.
Mat4 & operator/=(TIn _scale)
Inverse Scale each matrix component by _scale.
Mat4 operator+(const Mat4 &_rhs) const noexcept
Add term by term matrix values.
static Mat4 Lerp(const Mat4 &_start, const Mat4 &_end, float _alpha) noexcept
Clamped Lerp from _start to _end at _alpha.
static Mat4 MakeInverseView(const Vec3< T > &_eye, const Vec3< T > &_forward, const Vec3< T > &_up)
Make view matrix for camera.
constexpr Mat4(const Mat3< TIn, majorIn > &_other) noexcept
Value constructor from another Mat3 type.
static Mat4 LerpUnclamped(const Mat4 &_start, const Mat4 &_end, float _alpha) noexcept
Unclamped Lerp from _start to _end at _alpha.
static Mat4 MakeScale(const Vec3< T > &_scale) noexcept
Make scale matrix from vector3.
constexpr bool IsIdentity() const noexcept
Whether this matrix is an identity matrix.
Mat4 GetInversed() const
Inverse this matrix.
T Determinant() const noexcept
Compute the determinant of the matrix.
static const Mat4 Zero
Zero Mat4 constant.
Definition Matrix4.hpp:99
Quaternion Sapphire-Maths class.
Definition Quaternion.hpp:53
Vector 3 Sapphire-Maths class.
Definition Vector3.hpp:43
Vector 4 Sapphire-Maths class.
Definition Vector4.hpp:41