| 1 | #pragma once |
| 2 | |
| 3 | #include <math/seadMathPolicies.h> |
| 4 | #include <math/seadVector.h> |
| 5 | |
| 6 | namespace sead |
| 7 | { |
| 8 | template <typename T> |
| 9 | class Matrix22CalcCommon |
| 10 | { |
| 11 | public: |
| 12 | using Base = typename Policies<T>::Mtx22Base; |
| 13 | |
| 14 | public: |
| 15 | static void makeIdentity(Base& o); |
| 16 | static void makeZero(Base& o); |
| 17 | |
| 18 | static void copy(Base& o, const Base& n); |
| 19 | static void inverse(Base& o, const Base& n); |
| 20 | static void inverseTranspose(Base& o, const Base& n); |
| 21 | static void multiply(Base& o, const Base& a, const Base& b); |
| 22 | static void transpose(Base& o); |
| 23 | static void transposeTo(Base& o, const Base& n); |
| 24 | }; |
| 25 | |
| 26 | template <typename T> |
| 27 | class Matrix33CalcCommon |
| 28 | { |
| 29 | public: |
| 30 | using Base = typename Policies<T>::Mtx33Base; |
| 31 | using Mtx34 = typename Policies<T>::Mtx34Base; |
| 32 | |
| 33 | using Quat = typename Policies<T>::QuatBase; |
| 34 | using Vec3 = typename Policies<T>::Vec3Base; |
| 35 | |
| 36 | public: |
| 37 | static void makeIdentity(Base& o); |
| 38 | static void makeZero(Base& o); |
| 39 | |
| 40 | static void copy(Base& o, const Base& n); |
| 41 | static void copy(Base& o, const Mtx34& n); |
| 42 | static void inverse(Base& o, const Base& n); |
| 43 | static void inverseTranspose(Base& o, const Base& n); |
| 44 | static void multiply(Base& o, const Base& a, const Base& b); |
| 45 | static void multiply(Base& o, const Mtx34& a, const Base& b); |
| 46 | static void multiply(Base& o, const Base& a, const Mtx34& b); |
| 47 | static void transpose(Base& o); |
| 48 | static void transposeTo(Base& o, const Base& n); |
| 49 | |
| 50 | static void makeQ(Base& o, const Quat& q); |
| 51 | static void makeR(Base& o, const Vec3& r); |
| 52 | static void makeRIdx(Base& o, u32 xr, u32 yr, u32 zr); |
| 53 | static void makeRzxyIdx(Base& o, u32 xr, u32 yr, u32 zr); |
| 54 | static void makeS(Base& o, const Vec3& s); |
| 55 | static void makeSR(Base& o, const Vec3& s, const Vec3& r); |
| 56 | static void makeSRIdx(Base& o, const Vec3& s, const Vector3<u32>& r); |
| 57 | static void makeSRzxyIdx(Base& o, const Vec3& s, const Vector3<u32>& r); |
| 58 | static void toQuat(Quat& q, const Base& n); |
| 59 | |
| 60 | static void getBase(Vec3& v, const Base& n, s32 axis); |
| 61 | static void getRow(Vec3& v, const Base& n, s32 row); |
| 62 | |
| 63 | static void setBase(Base& n, s32 axis, const Vec3& v); |
| 64 | static void setRow(Base& n, const Vec3& v, s32 row); |
| 65 | }; |
| 66 | |
| 67 | template <typename T> |
| 68 | class Matrix34CalcCommon |
| 69 | { |
| 70 | public: |
| 71 | using Base = typename Policies<T>::Mtx34Base; |
| 72 | using Mtx33 = typename Policies<T>::Mtx33Base; |
| 73 | using Mtx44 = typename Policies<T>::Mtx44Base; |
| 74 | |
| 75 | using Quat = typename Policies<T>::QuatBase; |
| 76 | using Vec3 = typename Policies<T>::Vec3Base; |
| 77 | using Vec4 = typename Policies<T>::Vec4Base; |
| 78 | |
| 79 | public: |
| 80 | static void makeIdentity(Base& o); |
| 81 | static void makeZero(Base& o); |
| 82 | |
| 83 | static void copy(Base& o, const Base& n); |
| 84 | static void copy(Base& o, const Mtx33& n, const Vec3& t); |
| 85 | static void copy(Base& o, const Mtx44& n); |
| 86 | static bool inverse(Base& o, const Base& n); |
| 87 | static bool inverse33(Base& o, const Base& n); |
| 88 | static bool inverseTranspose(Base& o, const Base& n); |
| 89 | static void multiply(Base& o, const Base& a, const Base& b); |
| 90 | static void multiply(Base& o, const Mtx33& a, const Base& b); |
| 91 | static void multiply(Base& o, const Base& a, const Mtx33& b); |
| 92 | static void transpose(Base& o); |
| 93 | static void transposeTo(Base& o, const Base& n); |
| 94 | |
| 95 | static void makeQ(Base& o, const Quat& q); |
| 96 | static void makeQT(Base& o, const Quat& q, const Vec3& t); |
| 97 | static void makeR(Base& o, const Vec3& r); |
| 98 | static void makeRIdx(Base& o, u32 xr, u32 yr, u32 zr); |
| 99 | static void makeRT(Base& o, const Vec3& r, const Vec3& t); |
| 100 | static void makeRTIdx(Base& o, const Vector3<u32>& r, const Vec3& t); |
| 101 | static void makeRzxyIdx(Base& o, u32 xr, u32 yr, u32 zr); |
| 102 | static void makeRzxyTIdx(Base& o, const Vector3<u32>& r, const Vec3& t); |
| 103 | static void makeS(Base& o, const Vec3& s); |
| 104 | static void makeSQT(Base& o, const Vec3& s, const Quat& q, const Vec3& t); |
| 105 | static void makeSR(Base& o, const Vec3& s, const Vec3& r); |
| 106 | static void makeSRIdx(Base& o, const Vec3& s, const Vector3<u32>& r); |
| 107 | static void makeSRT(Base& o, const Vec3& s, const Vec3& r, const Vec3& t); |
| 108 | static void makeSRTIdx(Base& o, const Vec3& s, const Vector3<u32>& r, const Vec3& t); |
| 109 | static void makeSRzxyIdx(Base& o, const Vec3& s, const Vector3<u32>& r); |
| 110 | static void makeSRzxyTIdx(Base& o, const Vec3& s, const Vector3<u32>& r, const Vec3& t); |
| 111 | static void makeST(Base& o, const Vec3& s, const Vec3& t); |
| 112 | static void makeT(Base& o, const Vec3& t); |
| 113 | static void toQuat(Quat& q, const Base& n); |
| 114 | |
| 115 | static void getBase(Vec3& v, const Base& n, s32 axis); |
| 116 | static void getRow(Vec4& v, const Base& n, s32 row); |
| 117 | static void getTranslation(Vec3& v, const Base& n); |
| 118 | static void getRotation(Vec3& v, const Base& n); |
| 119 | |
| 120 | static void scaleAllElements(Base& n, T s); |
| 121 | static void scaleBases(Base& n, T sx, T sy, T sz); |
| 122 | static void setBase(Base& n, s32 axis, const Vec3& v); |
| 123 | static void setRow(Base& n, const Vec4& v, s32 row); |
| 124 | static void setTranslation(Base& n, const Vec3& v); |
| 125 | }; |
| 126 | |
| 127 | template <typename T> |
| 128 | class Matrix44CalcCommon |
| 129 | { |
| 130 | public: |
| 131 | using Base = typename Policies<T>::Mtx44Base; |
| 132 | using Mtx33 = typename Policies<T>::Mtx33Base; |
| 133 | using Mtx34 = typename Policies<T>::Mtx34Base; |
| 134 | |
| 135 | using Quat = typename Policies<T>::QuatBase; |
| 136 | using Vec3 = typename Policies<T>::Vec3Base; |
| 137 | using Vec4 = typename Policies<T>::Vec4Base; |
| 138 | |
| 139 | public: |
| 140 | static void makeIdentity(Base& o); |
| 141 | static void makeZero(Base& o); |
| 142 | |
| 143 | static void copy(Base& o, const Base& n); |
| 144 | static void copy(Base& o, const Mtx33& n, const Vec3& t, const Vec4& v); |
| 145 | static void copy(Base& o, const Mtx34& n, const Vec4& v); |
| 146 | static void inverse(Base& o, const Base& n); |
| 147 | static void inverseTranspose(Base& o, const Base& n); |
| 148 | static void multiply(Base& o, const Base& a, const Base& b); |
| 149 | static void multiply(Base& o, const Mtx34& a, const Base& b); |
| 150 | static void multiply(Base& o, const Base& a, const Mtx34& b); |
| 151 | static void transpose(Base& o); |
| 152 | static void transposeTo(Base& o, const Base& n); |
| 153 | |
| 154 | static void makeQ(Base& o, const Quat& q); |
| 155 | static void makeR(Base& o, const Vec3& r); |
| 156 | static void makeRIdx(Base& o, u32 xr, u32 yr, u32 zr); |
| 157 | static void makeRzxyIdx(Base& o, u32 xr, u32 yr, u32 zr); |
| 158 | static void toQuat(Quat& q, const Base& n); |
| 159 | |
| 160 | static void getCol(Vec4& v, const Base& n, s32 axis); |
| 161 | static void getRow(Vec4& v, const Base& n, s32 row); |
| 162 | |
| 163 | static void scaleAllElements(Base& n, T s); |
| 164 | static void scaleBases(Base& n, T sx, T sy, T sz, T sw); |
| 165 | static void setCol(Base& n, s32 axis, const Vec4& v); |
| 166 | static void setRow(Base& n, const Vec4& v, s32 row); |
| 167 | }; |
| 168 | |
| 169 | } // namespace sead |
| 170 | |
| 171 | #define SEAD_MATH_MATRIX_CALC_COMMON_H_ |
| 172 | #include <math/seadMatrixCalcCommon.hpp> |
| 173 | #undef SEAD_MATH_MATRIX_CALC_COMMON_H_ |
| 174 | |