sead
Loading...
Searching...
No Matches
seadMatrix.h
Go to the documentation of this file.
1#ifndef SEAD_MATRIX34_H_
2#define SEAD_MATRIX34_H_
3
4#include <math/seadQuat.h>
5#include <math/seadVector.h>
6
7namespace sead {
8
9template <typename T>
10class Matrix22;
11
12template <typename T>
13class Matrix33;
14
15template <typename T>
16class Matrix34;
17
18template <typename T>
19class Matrix44;
20
21template <typename T>
22class Matrix22 : public Policies<T>::Mtx22Base
23{
24private:
25 typedef Matrix22<T> Self;
26
27public:
29 {
30 }
31
32 //Matrix22(const Self& n)
33 //{
34 // operator=(n);
35 //}
36
38 T a00, T a01,
39 T a10, T a11
40 );
41
42 T operator()(s32 i, s32 j) const;
43 T& operator()(s32 i, s32 j);
44 Self& operator=(const Self& n);
45
47 void makeZero();
48
49 void setInverse(const Self& n);
50 void setInverseTranspose(const Self& n);
51 void setMul(const Self& a, const Self& b);
52 void setTranspose(const Self& n);
53 void transpose();
54
55 void makeRIdx(u32 r);
56
57 static const Matrix22 zero;
58 static const Matrix22 ident;
59};
60
61template <typename T>
62class Matrix33 : public Policies<T>::Mtx33Base
63{
64private:
65 typedef Matrix33<T> Self;
66 typedef Matrix34<T> Mtx34;
67
68 typedef Quat<T> Quat;
69 typedef Vector3<T> Vec3;
70
71public:
73 {
74 }
75
76 //Matrix33(const Self& n)
77 //{
78 // operator=(n);
79 //}
80
82 T a00, T a01, T a02,
83 T a10, T a11, T a12,
84 T a20, T a21, T a22
85 );
86
87 Matrix33(const Mtx34& mtx34);
88
89 T operator()(s32 i, s32 j) const;
90 T& operator()(s32 i, s32 j);
91 Self& operator=(const Self& n);
92
94 void makeZero();
95
96 void setInverse(const Self& n);
97 void setInverseTranspose(const Self& n);
98 void setMul(const Self& a, const Self& b);
99 void setMul(const Mtx34& a, const Self& b);
100 void setMul(const Self& a, const Mtx34& b);
101 void setTranspose(const Self& n);
102 void transpose();
103
104 void fromQuat(const Quat& q);
105 void makeR(const Vec3& r);
106 void makeRIdx(u32 xr, u32 yr, u32 zr);
107 void makeRzxyIdx(u32 xr, u32 yr, u32 zr);
108 void makeS(const Vec3& s);
109 void makeS(T x, T y, T z);
110 void makeSR(const Vec3& s, const Vec3& r);
111 void makeSRIdx(const Vec3& s, const Vector3<u32>& r);
112 void makeSRzxyIdx(const Vec3& s, const Vector3<u32>& r);
113 void toQuat(Quat& q) const;
114
115 static const Matrix33 zero;
116 static const Matrix33 ident;
117};
118
119template <typename T>
120class Matrix34 : public Policies<T>::Mtx34Base
121{
122private:
123 typedef Matrix34<T> Self;
124 typedef Matrix33<T> Mtx33;
125 typedef Matrix44<T> Mtx44;
126
127 typedef Quat<T> Quat;
128 typedef Vector3<T> Vec3;
129 typedef Vector4<T> Vec4;
130
131public:
133 {
134 }
135
136 //Matrix34(const Self& n)
137 //{
138 // operator=(n);
139 //}
140
142 T a00, T a01, T a02, T a03,
143 T a10, T a11, T a12, T a13,
144 T a20, T a21, T a22, T a23
145 );
146
147 Matrix34(const Mtx33& mtx33, const Vec3& t = Vec3::zero);
148 Matrix34(const Mtx44& mtx44);
149 Matrix34(const Matrix34& other) = default;
150
151 T operator()(s32 i, s32 j) const;
152 T& operator()(s32 i, s32 j);
153 Self& operator=(const Self& n);
154
156 void makeZero();
157
158 void setInverse(const Self& n);
159 void setInverse33(const Self& n);
160 void setInverseTranspose(const Self& n);
161 void setMul(const Self& a, const Self& b);
162 void setMul(const Mtx33& a, const Self& b);
163 void setTranspose(const Self& n);
164 void transpose();
165
166 void fromQuat(const Quat& q);
167 void makeR(const Vec3& r);
168 void makeRIdx(u32 xr, u32 yr, u32 zr);
169 void makeRT(const Vec3& r, const Vec3& t);
170 void makeRTIdx(const Vector3<u32>& r, const Vec3& t);
171 void makeRzxyIdx(u32 xr, u32 yr, u32 zr);
172 void makeRzxyIdx(const Vector3<u32>& r);
173 void makeRzxyTIdx(const Vector3<u32>& r, const Vec3& t);
174 void makeS(const Vec3& s);
175 void makeS(T x, T y, T z);
176 void makeSR(const Vec3& s, const Vec3& r);
177 void makeSRIdx(const Vec3& s, const Vector3<u32>& r);
178 void makeSRT(const Vec3& s, const Vec3& r, const Vec3& t);
179 void makeSRTIdx(const Vec3& s, const Vector3<u32>& r, const Vec3& t);
180 void makeSRzxyIdx(const Vec3& s, const Vector3<u32>& r);
181 void makeSRzxyTIdx(const Vec3& s, const Vector3<u32>& r, const Vec3& t);
182 void makeST(const Vec3& s, const Vec3& t);
183 void makeT(const Vec3& t);
184 void makeT(T x, T y, T z);
185 void toQuat(Quat& q) const;
186
188 void scaleBases(T s);
189 void scaleBases(T sx, T sy, T sz);
190 void scaleBases(const Vec3& s);
191
192 void multScaleLocal(const Vec3& s);
193 void setMultScaleLocal(const Self& n, const Vec3& s);
194
196 void setMultTranslationLocal(const Self& n, const Vec3& t);
197
198 void multScaleWorld(const Vec3& s);
199 void multScaleWorld(T x, T y, T z);
200 void setMultScaleWorld(const Vec3& s, const Self& n);
201 void setMultScaleWorld(T x, T y, T z, const Self& n);
202
204 void multTranslationWorld(T x, T y, T z);
205 void setMultTranslationWorld(const Vec3& t, const Self& n);
206 void setMultTranslationWorld(T x, T y, T z, const Self& n);
207
208 void getBase(Vec3& o, s32 axis) const;
209 Vec3 getBase(s32 axis) const;
210 void getRow(Vec4& o, s32 row) const;
211 Vec4 getRow(s32 row) const;
212 void getTranslation(Vec3& o) const;
214
215 void setBase(s32 axis, const Vec3& v);
216 void setRow(s32 row, const Vec4& v);
217 void setTranslation(const Vec3& t);
218 void setTranslation(T x, T y, T z);
219
220 static const Matrix34 zero;
221 static const Matrix34 ident;
222};
223
224template <typename T>
225class Matrix44 : public Policies<T>::Mtx44Base
226{
227private:
228 typedef Matrix44<T> Self;
229 typedef Matrix33<T> Mtx33;
230 typedef Matrix34<T> Mtx34;
231
232 typedef Quat<T> Quat;
233 typedef Vector3<T> Vec3;
234 typedef Vector4<T> Vec4;
235
236public:
238 {
239 }
240
241 //Matrix44(const Self& n)
242 //{
243 // operator=(n);
244 //}
245
247 T a00, T a01, T a02, T a03,
248 T a10, T a11, T a12, T a13,
249 T a20, T a21, T a22, T a23,
250 T a30, T a31, T a32, T a33
251 );
252
253 Matrix44(const Mtx33& mtx33, const Vec3& t = Vec3::zero, const Vec4& vw = Vec4::ew);
254 Matrix44(const Mtx34& mtx34, const Vec4& vw = Vec4::ew);
255
256 T operator()(s32 i, s32 j) const;
257 T& operator()(s32 i, s32 j);
258 Self& operator=(const Self& n);
259
261 void makeZero();
262
263 void setInverse(const Self& n);
264 void setInverseTranspose(const Self& n);
265 void setMul(const Self& a, const Self& b);
266 void setMul(const Mtx34& a, const Self& b);
267 void setMul(const Self& a, const Mtx34& b);
268 void setTranspose(const Self& n);
269 void transpose();
270
271 void fromQuat(const Quat& q);
272 void makeR(const Vec3& r);
273 void makeRIdx(u32 xr, u32 yr, u32 zr);
274 void makeRzxyIdx(u32 xr, u32 yr, u32 zr);
275 void toQuat(Quat& q) const;
276
278 void scaleBases(T sx, T sy, T sz, T sw);
279
280 void getCol(Vec4& o, s32 axis) const;
281 Vec4 getCol(s32 axis) const;
282 void getRow(Vec4& o, s32 row) const;
283 Vec4 getRow(s32 row) const;
284
285 void setCol(s32 axis, const Vec4& v);
286 void setRow(s32 row, const Vec4& v);
287
288 static const Matrix44 zero;
289 static const Matrix44 ident;
290};
291
292template <>
294
295template <>
297
298template <>
300
301template <>
303
304template <>
306
307template <>
309
310template <>
312
313template <>
315
316template <>
318
319template <>
321
322template <>
324
325template <>
327
328template <>
330
331template <>
333
334template <>
336
337template <>
339
344
345#ifdef cafe
346static_assert(sizeof(Matrix22f) == 0x10, "sead::Matrix22<T> size mismatch");
347static_assert(sizeof(Matrix33f) == 0x24, "sead::Matrix33<T> size mismatch");
348static_assert(sizeof(Matrix34f) == 0x30, "sead::Matrix34<T> size mismatch");
349static_assert(sizeof(Matrix44f) == 0x40, "sead::Matrix44<T> size mismatch");
350#endif // cafe
351
353
354} // namespace sead
355
356#ifdef __cplusplus
357
358#include <math/seadMatrix.hpp>
359
360#endif // __cplusplus
361
362#endif // SEAD_MATRIX34_H_
Definition seadMatrix.h:23
static const Matrix22 zero
Definition seadMatrix.h:57
Matrix22(T a00, T a01, T a10, T a11)
Definition seadMatrix.hpp:9
Matrix22()
Definition seadMatrix.h:28
void makeZero()
Definition seadMatrix.hpp:52
Matrix22< T > Self
Definition seadMatrix.h:25
static const Matrix22 ident
Definition seadMatrix.h:58
void setTranspose(const Self &n)
Definition seadMatrix.hpp:80
void setInverseTranspose(const Self &n)
Definition seadMatrix.hpp:66
void setMul(const Self &a, const Self &b)
Definition seadMatrix.hpp:73
void makeRIdx(u32 r)
Definition seadMatrix.hpp:94
void transpose()
Definition seadMatrix.hpp:87
T & operator()(s32 i, s32 j)
Definition seadMatrix.hpp:30
T operator()(s32 i, s32 j) const
Definition seadMatrix.hpp:23
Self & operator=(const Self &n)
Definition seadMatrix.hpp:37
void makeIdentity()
Definition seadMatrix.hpp:45
void setInverse(const Self &n)
Definition seadMatrix.hpp:59
Definition seadMatrix.h:63
Matrix33(T a00, T a01, T a02, T a10, T a11, T a12, T a20, T a21, T a22)
Definition seadMatrix.hpp:101
void makeR(const Vec3 &r)
Definition seadMatrix.hpp:222
void setMul(const Self &a, const Self &b)
Definition seadMatrix.hpp:180
void toQuat(Quat &q) const
Definition seadMatrix.hpp:279
void transpose()
Definition seadMatrix.hpp:208
void makeZero()
Definition seadMatrix.hpp:159
void fromQuat(const Quat &q)
Definition seadMatrix.hpp:215
T operator()(s32 i, s32 j) const
Definition seadMatrix.hpp:130
void makeSRzxyIdx(const Vec3 &s, const Vector3< u32 > &r)
Definition seadMatrix.hpp:272
void makeRIdx(u32 xr, u32 yr, u32 zr)
Definition seadMatrix.hpp:229
Vector3< T > Vec3
Definition seadMatrix.h:69
Matrix33()
Definition seadMatrix.h:72
static const Matrix33 zero
Definition seadMatrix.h:115
Self & operator=(const Self &n)
Definition seadMatrix.hpp:144
void makeSR(const Vec3 &s, const Vec3 &r)
Definition seadMatrix.hpp:258
void makeIdentity()
Definition seadMatrix.hpp:152
void makeS(const Vec3 &s)
Definition seadMatrix.hpp:243
Matrix33< T > Self
Definition seadMatrix.h:65
T & operator()(s32 i, s32 j)
Definition seadMatrix.hpp:137
void setInverseTranspose(const Self &n)
Definition seadMatrix.hpp:173
void setTranspose(const Self &n)
Definition seadMatrix.hpp:201
void setMul(const Self &a, const Mtx34 &b)
Definition seadMatrix.hpp:194
void setInverse(const Self &n)
Definition seadMatrix.hpp:166
void makeS(T x, T y, T z)
Definition seadMatrix.hpp:250
void setMul(const Mtx34 &a, const Self &b)
Definition seadMatrix.hpp:187
static const Matrix33 ident
Definition seadMatrix.h:116
Matrix33(const Mtx34 &mtx34)
Definition seadMatrix.hpp:123
void makeRzxyIdx(u32 xr, u32 yr, u32 zr)
Definition seadMatrix.hpp:236
Matrix34< T > Mtx34
Definition seadMatrix.h:66
void makeSRIdx(const Vec3 &s, const Vector3< u32 > &r)
Definition seadMatrix.hpp:265
Definition seadMatrix.h:121
void transpose()
Definition seadMatrix.hpp:402
void makeRT(const Vec3 &r, const Vec3 &t)
Definition seadMatrix.hpp:430
void makeS(T x, T y, T z)
Definition seadMatrix.hpp:472
Matrix34(T a00, T a01, T a02, T a03, T a10, T a11, T a12, T a13, T a20, T a21, T a22, T a23)
Definition seadMatrix.hpp:286
void makeSRT(const Vec3 &s, const Vec3 &r, const Vec3 &t)
Definition seadMatrix.hpp:494
void setRow(s32 row, const Vec4 &v)
Definition seadMatrix.hpp:762
Matrix34(const Mtx33 &mtx33, const Vec3 &t=Vec3::zero)
Definition seadMatrix.hpp:310
Vector4< T > Vec4
Definition seadMatrix.h:129
void makeSRzxyTIdx(const Vec3 &s, const Vector3< u32 > &r, const Vec3 &t)
Definition seadMatrix.hpp:515
Matrix34(const Mtx44 &mtx44)
Definition seadMatrix.hpp:317
void makeSR(const Vec3 &s, const Vec3 &r)
Definition seadMatrix.hpp:480
void makeT(T x, T y, T z)
Definition seadMatrix.hpp:536
void makeT(const Vec3 &t)
Definition seadMatrix.hpp:529
void getBase(Vec3 &o, s32 axis) const
Definition seadMatrix.hpp:679
Matrix34()
Definition seadMatrix.h:132
void makeRIdx(u32 xr, u32 yr, u32 zr)
Definition seadMatrix.hpp:423
void makeRzxyTIdx(const Vector3< u32 > &r, const Vec3 &t)
Definition seadMatrix.hpp:458
void setBase(s32 axis, const Vec3 &v)
Definition seadMatrix.hpp:755
static const Matrix34 ident
Definition seadMatrix.h:221
void toQuat(Quat &q) const
Definition seadMatrix.hpp:544
void scaleBases(T sx, T sy, T sz)
Definition seadMatrix.hpp:741
void setMultTranslationWorld(T x, T y, T z, const Self &n)
Definition seadMatrix.hpp:661
void makeSRTIdx(const Vec3 &s, const Vector3< u32 > &r, const Vec3 &t)
Definition seadMatrix.hpp:501
void makeRzxyIdx(u32 xr, u32 yr, u32 zr)
Definition seadMatrix.hpp:444
void makeSRzxyIdx(const Vec3 &s, const Vector3< u32 > &r)
Definition seadMatrix.hpp:508
void makeR(const Vec3 &r)
Definition seadMatrix.hpp:416
void setMultScaleWorld(T x, T y, T z, const Self &n)
Definition seadMatrix.hpp:611
void getTranslation(Vec3 &o) const
Definition seadMatrix.hpp:711
Matrix34< T > Self
Definition seadMatrix.h:123
void setInverse(const Self &n)
Definition seadMatrix.hpp:360
void multTranslationLocal(const Vec3 &t)
Definition seadMatrix.hpp:565
void scaleAllElements(T s)
Definition seadMatrix.hpp:727
void setMultScaleLocal(const Self &n, const Vec3 &s)
Definition seadMatrix.hpp:558
void setTranspose(const Self &n)
Definition seadMatrix.hpp:395
Matrix44< T > Mtx44
Definition seadMatrix.h:125
Self & operator=(const Self &n)
Definition seadMatrix.hpp:338
void makeRTIdx(const Vector3< u32 > &r, const Vec3 &t)
Definition seadMatrix.hpp:437
void scaleBases(const Vec3 &s)
Definition seadMatrix.hpp:748
void multTranslationWorld(T x, T y, T z)
Definition seadMatrix.hpp:636
void makeSRIdx(const Vec3 &s, const Vector3< u32 > &r)
Definition seadMatrix.hpp:487
void makeS(const Vec3 &s)
Definition seadMatrix.hpp:465
T & operator()(s32 i, s32 j)
Definition seadMatrix.hpp:331
void setTranslation(T x, T y, T z)
Definition seadMatrix.hpp:776
void getRow(Vec4 &o, s32 row) const
Definition seadMatrix.hpp:695
void makeRzxyIdx(const Vector3< u32 > &r)
Definition seadMatrix.hpp:451
Vec3 getBase(s32 axis) const
Definition seadMatrix.hpp:686
void makeZero()
Definition seadMatrix.hpp:353
void multTranslationWorld(const Vec3 &t)
Definition seadMatrix.hpp:629
void setMul(const Mtx33 &a, const Self &b)
Definition seadMatrix.hpp:388
Vector3< T > Vec3
Definition seadMatrix.h:128
void setMultScaleWorld(const Vec3 &s, const Self &n)
Definition seadMatrix.hpp:604
void multScaleLocal(const Vec3 &s)
Definition seadMatrix.hpp:551
void makeIdentity()
Definition seadMatrix.hpp:346
T operator()(s32 i, s32 j) const
Definition seadMatrix.hpp:324
void multScaleWorld(const Vec3 &s)
Definition seadMatrix.hpp:579
void setInverse33(const Self &n)
Definition seadMatrix.hpp:367
Matrix33< T > Mtx33
Definition seadMatrix.h:124
void setMultTranslationLocal(const Self &n, const Vec3 &t)
Definition seadMatrix.hpp:572
void setInverseTranspose(const Self &n)
Definition seadMatrix.hpp:374
static const Matrix34 zero
Definition seadMatrix.h:220
void setMul(const Self &a, const Self &b)
Definition seadMatrix.hpp:381
void setTranslation(const Vec3 &t)
Definition seadMatrix.hpp:769
Matrix34(const Matrix34 &other)=default
void setMultTranslationWorld(const Vec3 &t, const Self &n)
Definition seadMatrix.hpp:654
void scaleBases(T s)
Definition seadMatrix.hpp:734
void fromQuat(const Quat &q)
Definition seadMatrix.hpp:409
Vec4 getRow(s32 row) const
Definition seadMatrix.hpp:702
void multScaleWorld(T x, T y, T z)
Definition seadMatrix.hpp:586
Vec3 getTranslation() const
Definition seadMatrix.hpp:718
void makeST(const Vec3 &s, const Vec3 &t)
Definition seadMatrix.hpp:522
Definition seadMatrix.h:226
void setMul(const Self &a, const Self &b)
Definition seadMatrix.hpp:871
Matrix44(const Mtx33 &mtx33, const Vec3 &t=Vec3::zero, const Vec4 &vw=Vec4::ew)
Definition seadMatrix.hpp:814
Vec4 getRow(s32 row) const
Definition seadMatrix.hpp:964
T operator()(s32 i, s32 j) const
Definition seadMatrix.hpp:828
void makeIdentity()
Definition seadMatrix.hpp:850
void setCol(s32 axis, const Vec4 &v)
Definition seadMatrix.hpp:987
void makeRzxyIdx(u32 xr, u32 yr, u32 zr)
Definition seadMatrix.hpp:927
void transpose()
Definition seadMatrix.hpp:899
void fromQuat(const Quat &q)
Definition seadMatrix.hpp:906
Matrix44< T > Self
Definition seadMatrix.h:228
void makeRIdx(u32 xr, u32 yr, u32 zr)
Definition seadMatrix.hpp:920
void toQuat(Quat &q) const
Definition seadMatrix.hpp:934
Vector3< T > Vec3
Definition seadMatrix.h:233
Vector4< T > Vec4
Definition seadMatrix.h:234
void setInverse(const Self &n)
Definition seadMatrix.hpp:864
Self & operator=(const Self &n)
Definition seadMatrix.hpp:842
static const Matrix44 zero
Definition seadMatrix.h:288
static const Matrix44 ident
Definition seadMatrix.h:289
Matrix34< T > Mtx34
Definition seadMatrix.h:230
Vec4 getCol(s32 axis) const
Definition seadMatrix.hpp:948
void makeR(const Vec3 &r)
Definition seadMatrix.hpp:913
void setMul(const Self &a, const Mtx34 &b)
Definition seadMatrix.hpp:885
void setRow(s32 row, const Vec4 &v)
Definition seadMatrix.hpp:994
void scaleAllElements(T s)
Definition seadMatrix.hpp:973
void scaleBases(T sx, T sy, T sz, T sw)
Definition seadMatrix.hpp:980
T & operator()(s32 i, s32 j)
Definition seadMatrix.hpp:835
Matrix33< T > Mtx33
Definition seadMatrix.h:229
void setMul(const Mtx34 &a, const Self &b)
Definition seadMatrix.hpp:878
void setInverseTranspose(const Self &n)
Matrix44()
Definition seadMatrix.h:237
void makeZero()
Definition seadMatrix.hpp:857
Matrix44(const Mtx34 &mtx34, const Vec4 &vw=Vec4::ew)
Definition seadMatrix.hpp:821
void getCol(Vec4 &o, s32 axis) const
Definition seadMatrix.hpp:941
Matrix44(T a00, T a01, T a02, T a03, T a10, T a11, T a12, T a13, T a20, T a21, T a22, T a23, T a30, T a31, T a32, T a33)
Definition seadMatrix.hpp:784
void getRow(Vec4 &o, s32 row) const
Definition seadMatrix.hpp:957
void setTranspose(const Self &n)
Definition seadMatrix.hpp:892
Definition seadMathPolicies.h:8
Definition seadQuat.h:10
Definition seadVector.h:87
Definition seadVector.h:161
Definition seadAssert.h:44
Matrix33< f32 > Matrix33f
Definition seadMatrix.h:341
Matrix22< f32 > Matrix22f
Definition seadMatrix.h:340
Matrix44< f32 > Matrix44f
Definition seadMatrix.h:343
Matrix34< f32 > Matrixf
Definition seadMatrix.h:352
Matrix34< f32 > Matrix34f
Definition seadMatrix.h:342