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) { makeQ(q); };
105 void makeQ(const Quat& q);
106 void makeR(const Vec3& r);
107 void makeRIdx(u32 xr, u32 yr, u32 zr);
108 void makeRzxyIdx(u32 xr, u32 yr, u32 zr);
109 void makeS(const Vec3& s);
110 void makeS(T x, T y, T z);
111 void makeSR(const Vec3& s, const Vec3& r);
112 void makeSRIdx(const Vec3& s, const Vector3<u32>& r);
113 void makeSRzxyIdx(const Vec3& s, const Vector3<u32>& r);
114 void toQuat(Quat& q) const;
115
116 static const Matrix33 zero;
117 static const Matrix33 ident;
118};
119
120template <typename T>
121class Matrix34 : public Policies<T>::Mtx34Base
122{
123private:
124 typedef Matrix34<T> Self;
125 typedef Matrix33<T> Mtx33;
126 typedef Matrix44<T> Mtx44;
127
128 typedef Quat<T> Quat;
129 typedef Vector3<T> Vec3;
130 typedef Vector4<T> Vec4;
131
132public:
134 {
135 }
136
137 //Matrix34(const Self& n)
138 //{
139 // operator=(n);
140 //}
141
143 T a00, T a01, T a02, T a03,
144 T a10, T a11, T a12, T a13,
145 T a20, T a21, T a22, T a23
146 );
147
148 Matrix34(const Mtx33& mtx33, const Vec3& t = Vec3::zero);
149 Matrix34(const Mtx44& mtx44);
150 Matrix34(const Matrix34& other) = default;
151
152 T operator()(s32 i, s32 j) const;
153 T& operator()(s32 i, s32 j);
154 Self& operator=(const Self& n);
155
157 void makeZero();
158
159 void setInverse(const Self& n);
160 void setInverse33(const Self& n);
161 void setInverseTranspose(const Self& n);
162 void setMul(const Self& a, const Self& b);
163 void setMul(const Mtx33& a, const Self& b);
164 void setTranspose(const Self& n);
165 void transpose();
166
167 void fromQuat(const Quat& q) { makeQ(q); };
168 void makeQ(const Quat& q);
169 void makeQ(T w, T x, T y, T z);
170 void makeQT(const Quat& q, const Vec3& t);
171 void makeR(const Vec3& r);
172 void makeRIdx(u32 xr, u32 yr, u32 zr);
173 void makeRT(const Vec3& r, const Vec3& t);
174 void makeRTIdx(const Vector3<u32>& r, const Vec3& t);
175 void makeRzxyIdx(u32 xr, u32 yr, u32 zr);
176 void makeRzxyIdx(const Vector3<u32>& r);
177 void makeRzxyTIdx(const Vector3<u32>& r, const Vec3& t);
178 void makeS(const Vec3& s);
179 void makeS(T x, T y, T z);
180 void makeSQ(const Vec3& s, const Quat& q);
181 void makeSQT(const Vec3& s, const Quat& q, const Vec3& t);
182 void makeSR(const Vec3& s, const Vec3& r);
183 void makeSRIdx(const Vec3& s, const Vector3<u32>& r);
184 void makeSRT(const Vec3& s, const Vec3& r, const Vec3& t);
185 void makeSRTIdx(const Vec3& s, const Vector3<u32>& r, const Vec3& t);
186 void makeSRzxyIdx(const Vec3& s, const Vector3<u32>& r);
187 void makeSRzxyTIdx(const Vec3& s, const Vector3<u32>& r, const Vec3& t);
188 void makeST(const Vec3& s, const Vec3& t);
189 void makeT(const Vec3& t);
190 void makeT(T x, T y, T z);
191 void toQuat(Quat& q) const;
192
194 void scaleBases(T s);
195 void scaleBases(T sx, T sy, T sz);
196 void scaleBases(const Vec3& s);
197
198 void multScaleLocal(const Vec3& s);
199 void setMultScaleLocal(const Self& n, const Vec3& s);
200
202 void setMultTranslationLocal(const Self& n, const Vec3& t);
203
204 void multScaleWorld(const Vec3& s);
205 void multScaleWorld(T x, T y, T z);
206 void setMultScaleWorld(const Vec3& s, const Self& n);
207 void setMultScaleWorld(T x, T y, T z, const Self& n);
208
210 void multTranslationWorld(T x, T y, T z);
211 void setMultTranslationWorld(const Vec3& t, const Self& n);
212 void setMultTranslationWorld(T x, T y, T z, const Self& n);
213
214 void getBase(Vec3& o, s32 axis) const;
215 Vec3 getBase(s32 axis) const;
216 void getRow(Vec4& o, s32 row) const;
217 Vec4 getRow(s32 row) const;
218 void getTranslation(Vec3& o) const;
220
221 void setBase(s32 axis, const Vec3& v);
222 void setRow(s32 row, const Vec4& v);
223 void setTranslation(const Vec3& t);
224 void setTranslation(T x, T y, T z);
225
226 static const Matrix34 zero;
227 static const Matrix34 ident;
228};
229
230template <typename T>
231class Matrix44 : public Policies<T>::Mtx44Base
232{
233private:
234 typedef Matrix44<T> Self;
235 typedef Matrix33<T> Mtx33;
236 typedef Matrix34<T> Mtx34;
237
238 typedef Quat<T> Quat;
239 typedef Vector3<T> Vec3;
240 typedef Vector4<T> Vec4;
241
242public:
244 {
245 }
246
247 //Matrix44(const Self& n)
248 //{
249 // operator=(n);
250 //}
251
253 T a00, T a01, T a02, T a03,
254 T a10, T a11, T a12, T a13,
255 T a20, T a21, T a22, T a23,
256 T a30, T a31, T a32, T a33
257 );
258
259 Matrix44(const Mtx33& mtx33, const Vec3& t = Vec3::zero, const Vec4& vw = Vec4::ew);
260 Matrix44(const Mtx34& mtx34, const Vec4& vw = Vec4::ew);
261
262 T operator()(s32 i, s32 j) const;
263 T& operator()(s32 i, s32 j);
264 Self& operator=(const Self& n);
265
267 void makeZero();
268
269 void setInverse(const Self& n);
270 void setInverseTranspose(const Self& n);
271 void setMul(const Self& a, const Self& b);
272 void setMul(const Mtx34& a, const Self& b);
273 void setMul(const Self& a, const Mtx34& b);
274 void setTranspose(const Self& n);
275 void transpose();
276
277 void fromQuat(const Quat& q) { makeQ(q); };
278 void makeQ(const Quat& q);
279 void makeR(const Vec3& r);
280 void makeRIdx(u32 xr, u32 yr, u32 zr);
281 void makeRzxyIdx(u32 xr, u32 yr, u32 zr);
282 void toQuat(Quat& q) const;
283
285 void scaleBases(T sx, T sy, T sz, T sw);
286
287 void getCol(Vec4& o, s32 axis) const;
288 Vec4 getCol(s32 axis) const;
289 void getRow(Vec4& o, s32 row) const;
290 Vec4 getRow(s32 row) const;
291
292 void setCol(s32 axis, const Vec4& v);
293 void setRow(s32 row, const Vec4& v);
294
295 static const Matrix44 zero;
296 static const Matrix44 ident;
297};
298
299template <>
301
302template <>
304
305template <>
307
308template <>
310
311template <>
313
314template <>
316
317template <>
319
320template <>
322
323template <>
325
326template <>
328
329template <>
331
332template <>
334
335template <>
337
338template <>
340
341template <>
343
344template <>
346
351
352#ifdef cafe
353static_assert(sizeof(Matrix22f) == 0x10, "sead::Matrix22<T> size mismatch");
354static_assert(sizeof(Matrix33f) == 0x24, "sead::Matrix33<T> size mismatch");
355static_assert(sizeof(Matrix34f) == 0x30, "sead::Matrix34<T> size mismatch");
356static_assert(sizeof(Matrix44f) == 0x40, "sead::Matrix44<T> size mismatch");
357#endif // cafe
358
360
361} // namespace sead
362
363#ifdef __cplusplus
364
365#include <math/seadMatrix.hpp>
366
367#endif // __cplusplus
368
369#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.h:104
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:116
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 makeQ(const Quat &q)
Definition seadMatrix.hpp:215
void setMul(const Mtx34 &a, const Self &b)
Definition seadMatrix.hpp:187
static const Matrix33 ident
Definition seadMatrix.h:117
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:122
void transpose()
Definition seadMatrix.hpp:402
void makeRT(const Vec3 &r, const Vec3 &t)
Definition seadMatrix.hpp:445
void makeS(T x, T y, T z)
Definition seadMatrix.hpp:487
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:523
void setRow(s32 row, const Vec4 &v)
Definition seadMatrix.hpp:791
void makeQ(T w, T x, T y, T z)
Definition seadMatrix.hpp:416
Matrix34(const Mtx33 &mtx33, const Vec3 &t=Vec3::zero)
Definition seadMatrix.hpp:310
void makeQ(const Quat &q)
Definition seadMatrix.hpp:409
Vector4< T > Vec4
Definition seadMatrix.h:130
void makeSRzxyTIdx(const Vec3 &s, const Vector3< u32 > &r, const Vec3 &t)
Definition seadMatrix.hpp:544
Matrix34(const Mtx44 &mtx44)
Definition seadMatrix.hpp:317
void makeSR(const Vec3 &s, const Vec3 &r)
Definition seadMatrix.hpp:509
void makeT(T x, T y, T z)
Definition seadMatrix.hpp:565
void makeT(const Vec3 &t)
Definition seadMatrix.hpp:558
void getBase(Vec3 &o, s32 axis) const
Definition seadMatrix.hpp:708
Matrix34()
Definition seadMatrix.h:133
void makeRIdx(u32 xr, u32 yr, u32 zr)
Definition seadMatrix.hpp:438
void makeRzxyTIdx(const Vector3< u32 > &r, const Vec3 &t)
Definition seadMatrix.hpp:473
void setBase(s32 axis, const Vec3 &v)
Definition seadMatrix.hpp:784
static const Matrix34 ident
Definition seadMatrix.h:227
void toQuat(Quat &q) const
Definition seadMatrix.hpp:573
void scaleBases(T sx, T sy, T sz)
Definition seadMatrix.hpp:770
void setMultTranslationWorld(T x, T y, T z, const Self &n)
Definition seadMatrix.hpp:690
void makeSRTIdx(const Vec3 &s, const Vector3< u32 > &r, const Vec3 &t)
Definition seadMatrix.hpp:530
void makeRzxyIdx(u32 xr, u32 yr, u32 zr)
Definition seadMatrix.hpp:459
void makeSRzxyIdx(const Vec3 &s, const Vector3< u32 > &r)
Definition seadMatrix.hpp:537
void makeR(const Vec3 &r)
Definition seadMatrix.hpp:431
void setMultScaleWorld(T x, T y, T z, const Self &n)
Definition seadMatrix.hpp:640
void makeSQ(const Vec3 &s, const Quat &q)
Definition seadMatrix.hpp:495
void getTranslation(Vec3 &o) const
Definition seadMatrix.hpp:740
Matrix34< T > Self
Definition seadMatrix.h:124
void setInverse(const Self &n)
Definition seadMatrix.hpp:360
void multTranslationLocal(const Vec3 &t)
Definition seadMatrix.hpp:594
void scaleAllElements(T s)
Definition seadMatrix.hpp:756
void setMultScaleLocal(const Self &n, const Vec3 &s)
Definition seadMatrix.hpp:587
void setTranspose(const Self &n)
Definition seadMatrix.hpp:395
Matrix44< T > Mtx44
Definition seadMatrix.h:126
Self & operator=(const Self &n)
Definition seadMatrix.hpp:338
void makeRTIdx(const Vector3< u32 > &r, const Vec3 &t)
Definition seadMatrix.hpp:452
void scaleBases(const Vec3 &s)
Definition seadMatrix.hpp:777
void multTranslationWorld(T x, T y, T z)
Definition seadMatrix.hpp:665
void makeSRIdx(const Vec3 &s, const Vector3< u32 > &r)
Definition seadMatrix.hpp:516
void makeS(const Vec3 &s)
Definition seadMatrix.hpp:480
T & operator()(s32 i, s32 j)
Definition seadMatrix.hpp:331
void setTranslation(T x, T y, T z)
Definition seadMatrix.hpp:805
void getRow(Vec4 &o, s32 row) const
Definition seadMatrix.hpp:724
void makeRzxyIdx(const Vector3< u32 > &r)
Definition seadMatrix.hpp:466
Vec3 getBase(s32 axis) const
Definition seadMatrix.hpp:715
void makeZero()
Definition seadMatrix.hpp:353
void multTranslationWorld(const Vec3 &t)
Definition seadMatrix.hpp:658
void makeSQT(const Vec3 &s, const Quat &q, const Vec3 &t)
Definition seadMatrix.hpp:502
void setMul(const Mtx33 &a, const Self &b)
Definition seadMatrix.hpp:388
Vector3< T > Vec3
Definition seadMatrix.h:129
void setMultScaleWorld(const Vec3 &s, const Self &n)
Definition seadMatrix.hpp:633
void multScaleLocal(const Vec3 &s)
Definition seadMatrix.hpp:580
void makeIdentity()
Definition seadMatrix.hpp:346
void makeQT(const Quat &q, const Vec3 &t)
Definition seadMatrix.hpp:424
T operator()(s32 i, s32 j) const
Definition seadMatrix.hpp:324
void multScaleWorld(const Vec3 &s)
Definition seadMatrix.hpp:608
void setInverse33(const Self &n)
Definition seadMatrix.hpp:367
Matrix33< T > Mtx33
Definition seadMatrix.h:125
void setMultTranslationLocal(const Self &n, const Vec3 &t)
Definition seadMatrix.hpp:601
void setInverseTranspose(const Self &n)
Definition seadMatrix.hpp:374
static const Matrix34 zero
Definition seadMatrix.h:226
void setMul(const Self &a, const Self &b)
Definition seadMatrix.hpp:381
void setTranslation(const Vec3 &t)
Definition seadMatrix.hpp:798
Matrix34(const Matrix34 &other)=default
void setMultTranslationWorld(const Vec3 &t, const Self &n)
Definition seadMatrix.hpp:683
void scaleBases(T s)
Definition seadMatrix.hpp:763
void fromQuat(const Quat &q)
Definition seadMatrix.h:167
Vec4 getRow(s32 row) const
Definition seadMatrix.hpp:731
void multScaleWorld(T x, T y, T z)
Definition seadMatrix.hpp:615
Vec3 getTranslation() const
Definition seadMatrix.hpp:747
void makeST(const Vec3 &s, const Vec3 &t)
Definition seadMatrix.hpp:551
Definition seadMatrix.h:232
void setMul(const Self &a, const Self &b)
Definition seadMatrix.hpp:900
Matrix44(const Mtx33 &mtx33, const Vec3 &t=Vec3::zero, const Vec4 &vw=Vec4::ew)
Definition seadMatrix.hpp:843
Vec4 getRow(s32 row) const
Definition seadMatrix.hpp:993
T operator()(s32 i, s32 j) const
Definition seadMatrix.hpp:857
void makeQ(const Quat &q)
Definition seadMatrix.hpp:935
void makeIdentity()
Definition seadMatrix.hpp:879
void setCol(s32 axis, const Vec4 &v)
Definition seadMatrix.hpp:1016
void makeRzxyIdx(u32 xr, u32 yr, u32 zr)
Definition seadMatrix.hpp:956
void transpose()
Definition seadMatrix.hpp:928
void fromQuat(const Quat &q)
Definition seadMatrix.h:277
Matrix44< T > Self
Definition seadMatrix.h:234
void makeRIdx(u32 xr, u32 yr, u32 zr)
Definition seadMatrix.hpp:949
void toQuat(Quat &q) const
Definition seadMatrix.hpp:963
Vector3< T > Vec3
Definition seadMatrix.h:239
Vector4< T > Vec4
Definition seadMatrix.h:240
void setInverse(const Self &n)
Definition seadMatrix.hpp:893
Self & operator=(const Self &n)
Definition seadMatrix.hpp:871
static const Matrix44 zero
Definition seadMatrix.h:295
static const Matrix44 ident
Definition seadMatrix.h:296
Matrix34< T > Mtx34
Definition seadMatrix.h:236
Vec4 getCol(s32 axis) const
Definition seadMatrix.hpp:977
void makeR(const Vec3 &r)
Definition seadMatrix.hpp:942
void setMul(const Self &a, const Mtx34 &b)
Definition seadMatrix.hpp:914
void setRow(s32 row, const Vec4 &v)
Definition seadMatrix.hpp:1023
void scaleAllElements(T s)
Definition seadMatrix.hpp:1002
void scaleBases(T sx, T sy, T sz, T sw)
Definition seadMatrix.hpp:1009
T & operator()(s32 i, s32 j)
Definition seadMatrix.hpp:864
Matrix33< T > Mtx33
Definition seadMatrix.h:235
void setMul(const Mtx34 &a, const Self &b)
Definition seadMatrix.hpp:907
void setInverseTranspose(const Self &n)
Matrix44()
Definition seadMatrix.h:243
void makeZero()
Definition seadMatrix.hpp:886
Matrix44(const Mtx34 &mtx34, const Vec4 &vw=Vec4::ew)
Definition seadMatrix.hpp:850
void getCol(Vec4 &o, s32 axis) const
Definition seadMatrix.hpp:970
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:813
void getRow(Vec4 &o, s32 row) const
Definition seadMatrix.hpp:986
void setTranspose(const Self &n)
Definition seadMatrix.hpp:921
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:348
Matrix22< f32 > Matrix22f
Definition seadMatrix.h:347
Matrix44< f32 > Matrix44f
Definition seadMatrix.h:350
Matrix34< f32 > Matrixf
Definition seadMatrix.h:359
Matrix34< f32 > Matrix34f
Definition seadMatrix.h:349