#pragma once #include #include #include #include namespace sead { template class Matrix22; template class Matrix33; template class Matrix34; template class Matrix44; template class Matrix22 : public Policies::Mtx22Base { private: using Self = Matrix22; public: Matrix22() {} Matrix22(const Self& n) = default; Matrix22(T a00, T a01, T a10, T a11); T operator()(s32 i, s32 j) const; T& operator()(s32 i, s32 j); Self& operator=(const Self& n); void makeIdentity(); void makeZero(); void setInverse(const Self& n); void setInverseTranspose(const Self& n); void setMul(const Self& a, const Self& b); void setTranspose(const Self& n); void transpose(); static const Matrix22 zero; static const Matrix22 ident; }; template class Matrix33 : public Policies::Mtx33Base { private: using Self = Matrix33; using Mtx34 = Matrix34; using Vec3 = Vector3; public: Matrix33() {} Matrix33(const Self& n) = default; Matrix33(T a00, T a01, T a02, T a10, T a11, T a12, T a20, T a21, T a22); Matrix33(const Mtx34& mtx34); T operator()(s32 i, s32 j) const; T& operator()(s32 i, s32 j); Self& operator=(const Self& n); void makeIdentity(); void makeZero(); void setInverse(const Self& n); void setInverseTranspose(const Self& n); void setMul(const Self& a, const Self& b); void setMul(const Mtx34& a, const Self& b); void setMul(const Self& a, const Mtx34& b); void setTranspose(const Self& n); void transpose(); void fromQuat(const Quat& q); void makeR(const Vec3& r); void makeRIdx(u32 xr, u32 yr, u32 zr); void makeRzxyIdx(u32 xr, u32 yr, u32 zr); void makeS(const Vec3& s); void makeS(T x, T y, T z); void makeSR(const Vec3& s, const Vec3& r); void makeSRIdx(const Vec3& s, const Vector3& r); void makeSRzxyIdx(const Vec3& s, const Vector3& r); void toQuat(Quat& q) const; static const Matrix33 zero; static const Matrix33 ident; }; template class Matrix34 : public Policies::Mtx34Base { private: using Self = Matrix34; using Mtx33 = Matrix33; using Mtx44 = Matrix44; using Vec3 = Vector3; using Vec4 = Vector4; public: Matrix34() {} Matrix34(const Self& n) = default; Matrix34(T _00, T _01, T _02, T _03, T _10, T _11, T _12, T _13, T _20, T _21, T _22, T _23); Matrix34(const Mtx33& mtx33, const Vec3& t = Vec3::zero); Matrix34(const Mtx44& mtx44); T operator()(s32 i, s32 j) const; T& operator()(s32 i, s32 j); Self& operator=(const Self& n); void makeIdentity(); void makeZero(); void setInverse(const Self& n); void setInverse33(const Self& n); void setInverseTranspose(const Self& n); void setMul(const Self& a, const Self& b); void setMul(const Mtx33& a, const Self& b); void setTranspose(const Self& n); void transpose(); void fromQuat(const Quat& q); void makeQT(const Quat& q, const Vec3& t); void makeR(const Vec3& r); void makeRIdx(u32 xr, u32 yr, u32 zr); void makeRT(const Vec3& r, const Vec3& t); void makeRTIdx(const Vector3& r, const Vec3& t); void makeRzxyIdx(u32 xr, u32 yr, u32 zr); void makeRzxyTIdx(const Vector3& r, const Vec3& t); void makeS(const Vec3& s); void makeS(T x, T y, T z); void makeSR(const Vec3& s, const Vec3& r); void makeSRIdx(const Vec3& s, const Vector3& r); void makeSRT(const Vec3& s, const Vec3& r, const Vec3& t); void makeSRTIdx(const Vec3& s, const Vector3& r, const Vec3& t); void makeSRzxyIdx(const Vec3& s, const Vector3& r); void makeSRzxyTIdx(const Vec3& s, const Vector3& r, const Vec3& t); void makeST(const Vec3& s, const Vec3& t); void makeT(const Vec3& t); void makeT(T x, T y, T z); void toQuat(Quat& q) const; void getBase(Vec3& o, s32 axis) const; void getRow(Vec4& o, s32 row) const; void getTranslation(Vec3& o) const; void getRotation(Vec3& o) const; void scaleAllElements(T s); void scaleBases(T sx, T sy, T sz); void setBase(s32 axis, const Vec3& v); void setRow(s32 row, const Vec4& v); void setTranslation(const Vec3& t); void setTranslation(T x, T y, T z); static const Matrix34 zero; static const Matrix34 ident; }; template class Matrix44 : public Policies::Mtx44Base { private: using Self = Matrix44; using Mtx33 = Matrix33; using Mtx34 = Matrix34; using Vec3 = Vector3; using Vec4 = Vector4; public: Matrix44() {} Matrix44(const Self& n) = default; Matrix44(T _00, T _01, T _02, T _03, T _10, T _11, T _12, T _13, T _20, T _21, T _22, T _23, T _30, T _31, T _32, T _33); Matrix44(const Mtx33& mtx33, const Vec3& t = Vec3::zero, const Vec4& vw = Vec4::ew); Matrix44(const Mtx34& mtx34, const Vec4& vw = Vec4::ew); T operator()(s32 i, s32 j) const; T& operator()(s32 i, s32 j); Self& operator=(const Self& n); void makeIdentity(); void makeZero(); void setInverse(const Self& n); void setInverseTranspose(const Self& n); void setMul(const Self& a, const Self& b); void setMul(const Mtx34& a, const Self& b); void setMul(const Self& a, const Mtx34& b); void setTranspose(const Self& n); void transpose(); void fromQuat(const Quat& q); void makeR(const Vec3& r); void makeRIdx(u32 xr, u32 yr, u32 zr); void makeRzxyIdx(u32 xr, u32 yr, u32 zr); void toQuat(Quat& q) const; void getCol(Vec4& o, s32 axis) const; void getRow(Vec4& o, s32 row) const; void scaleAllElements(T s); void scaleBases(T sx, T sy, T sz, T sw); void setCol(s32 axis, const Vec4& v); void setRow(s32 row, const Vec4& v); static const Matrix44 zero; static const Matrix44 ident; }; typedef Matrix22 Matrix22f; typedef Matrix33 Matrix33f; typedef Matrix34 Matrix34f; typedef Matrix44 Matrix44f; typedef Matrix34 Matrixf; template <> const Matrix22f Matrix22f::zero; template <> const Matrix22f Matrix22f::ident; template <> const Matrix33f Matrix33f::zero; template <> const Matrix33f Matrix33f::ident; template <> const Matrix34f Matrix34f::zero; template <> const Matrix34f Matrix34f::ident; template <> const Matrix44f Matrix44f::zero; template <> const Matrix44f Matrix44f::ident; template <> const Matrix22 Matrix22::zero; template <> const Matrix22 Matrix22::ident; template <> const Matrix33 Matrix33::zero; template <> const Matrix33 Matrix33::ident; template <> const Matrix34 Matrix34::zero; template <> const Matrix34 Matrix34::ident; template <> const Matrix44 Matrix44::zero; template <> const Matrix44 Matrix44::ident; } // namespace sead #define SEAD_MATH_MATRIX_H_ #include #undef SEAD_MATH_MATRIX_H_