1#pragma once
2
3#include <math/seadMatrixCalcCommon.h>
4#ifndef SEAD_MATH_MATRIX_H_
5#include <math/seadMatrix.h>
6#endif
7
8namespace sead
9{
10template <typename T>
11inline Matrix22<T>::Matrix22(T a00, T a01, T a10, T a11)
12{
13 this->m[0][0] = a00;
14 this->m[0][1] = a01;
15
16 this->m[1][0] = a10;
17 this->m[1][1] = a11;
18}
19
20template <typename T>
21inline T Matrix22<T>::operator()(s32 i, s32 j) const
22{
23 return this->m[i][j];
24}
25
26template <typename T>
27inline T& Matrix22<T>::operator()(s32 i, s32 j)
28{
29 return this->m[i][j];
30}
31
32template <typename T>
33inline Matrix22<T>& Matrix22<T>::operator=(const Self& n)
34{
35 Matrix22CalcCommon<T>::copy(*this, n);
36 return *this;
37}
38
39template <typename T>
40inline void Matrix22<T>::makeIdentity()
41{
42 Matrix22CalcCommon<T>::makeIdentity(*this);
43}
44
45template <typename T>
46inline void Matrix22<T>::makeZero()
47{
48 Matrix22CalcCommon<T>::makeZero(*this);
49}
50
51template <typename T>
52inline void Matrix22<T>::setInverse(const Self& n)
53{
54 Matrix22CalcCommon<T>::inverse(*this, n);
55}
56
57template <typename T>
58inline void Matrix22<T>::setInverseTranspose(const Self& n)
59{
60 Matrix22CalcCommon<T>::inverseTranspose(*this, n);
61}
62
63template <typename T>
64inline void Matrix22<T>::setMul(const Self& a, const Self& b)
65{
66 Matrix22CalcCommon<T>::multiply(*this, a, b);
67}
68
69template <typename T>
70inline void Matrix22<T>::setTranspose(const Self& n)
71{
72 Matrix22CalcCommon<T>::transposeTo(*this, n);
73}
74
75template <typename T>
76inline void Matrix22<T>::transpose()
77{
78 Matrix22CalcCommon<T>::transpose(*this);
79}
80
81template <typename T>
82inline Matrix33<T>::Matrix33(T a00, T a01, T a02, T a10, T a11, T a12, T a20, T a21, T a22)
83{
84 this->m[0][0] = a00;
85 this->m[0][1] = a01;
86 this->m[0][2] = a02;
87
88 this->m[1][0] = a10;
89 this->m[1][1] = a11;
90 this->m[1][2] = a12;
91
92 this->m[2][0] = a20;
93 this->m[2][1] = a21;
94 this->m[2][2] = a22;
95}
96
97template <typename T>
98inline Matrix33<T>::Matrix33(const Mtx34& mtx34)
99{
100 Matrix33CalcCommon<T>::copy(*this, mtx34);
101}
102
103template <typename T>
104inline T Matrix33<T>::operator()(s32 i, s32 j) const
105{
106 return this->m[i][j];
107}
108
109template <typename T>
110inline T& Matrix33<T>::operator()(s32 i, s32 j)
111{
112 return this->m[i][j];
113}
114
115template <typename T>
116inline Matrix33<T>& Matrix33<T>::operator=(const Self& n)
117{
118 Matrix33CalcCommon<T>::copy(*this, n);
119 return *this;
120}
121
122template <typename T>
123inline void Matrix33<T>::makeIdentity()
124{
125 Matrix33CalcCommon<T>::makeIdentity(*this);
126}
127
128template <typename T>
129inline void Matrix33<T>::makeZero()
130{
131 Matrix33CalcCommon<T>::makeZero(*this);
132}
133
134template <typename T>
135inline void Matrix33<T>::setInverse(const Self& n)
136{
137 Matrix33CalcCommon<T>::inverse(*this, n);
138}
139
140template <typename T>
141inline void Matrix33<T>::setInverseTranspose(const Self& n)
142{
143 Matrix33CalcCommon<T>::inverseTranspose(*this, n);
144}
145
146template <typename T>
147inline void Matrix33<T>::setMul(const Self& a, const Self& b)
148{
149 Matrix33CalcCommon<T>::multiply(*this, a, b);
150}
151
152template <typename T>
153inline void Matrix33<T>::setMul(const Mtx34& a, const Self& b)
154{
155 Matrix33CalcCommon<T>::multiply(*this, a, b);
156}
157
158template <typename T>
159inline void Matrix33<T>::setMul(const Self& a, const Mtx34& b)
160{
161 Matrix33CalcCommon<T>::multiply(*this, a, b);
162}
163
164template <typename T>
165inline void Matrix33<T>::setTranspose(const Self& n)
166{
167 Matrix33CalcCommon<T>::transposeTo(*this, n);
168}
169
170template <typename T>
171inline void Matrix33<T>::transpose()
172{
173 Matrix33CalcCommon<T>::transpose(*this);
174}
175
176template <typename T>
177inline void Matrix33<T>::fromQuat(const Quat<T>& q)
178{
179 Matrix33CalcCommon<T>::makeQ(*this, q);
180}
181
182template <typename T>
183inline void Matrix33<T>::makeR(const Vec3& r)
184{
185 Matrix33CalcCommon<T>::makeR(*this, r);
186}
187
188template <typename T>
189inline void Matrix33<T>::makeRIdx(u32 xr, u32 yr, u32 zr)
190{
191 Matrix33CalcCommon<T>::makeRIdx(*this, xr, yr, zr);
192}
193
194template <typename T>
195inline void Matrix33<T>::makeRzxyIdx(u32 xr, u32 yr, u32 zr)
196{
197 Matrix33CalcCommon<T>::makeRzxyIdx(*this, xr, yr, zr);
198}
199
200template <typename T>
201inline void Matrix33<T>::makeS(const Vec3& s)
202{
203 Matrix33CalcCommon<T>::makeS(*this, s);
204}
205
206template <typename T>
207inline void Matrix33<T>::makeS(T x, T y, T z)
208{
209 Vec3 s(x, y, z);
210 Matrix33CalcCommon<T>::makeS(*this, s);
211}
212
213template <typename T>
214inline void Matrix33<T>::makeSR(const Vec3& s, const Vec3& r)
215{
216 Matrix33CalcCommon<T>::makeSR(*this, s, r);
217}
218
219template <typename T>
220inline void Matrix33<T>::makeSRIdx(const Vec3& s, const Vector3<u32>& r)
221{
222 Matrix33CalcCommon<T>::makeSRIdx(*this, s, r);
223}
224
225template <typename T>
226inline void Matrix33<T>::makeSRzxyIdx(const Vec3& s, const Vector3<u32>& r)
227{
228 Matrix33CalcCommon<T>::makeSRzxyIdx(*this, s, r);
229}
230
231template <typename T>
232inline void Matrix33<T>::toQuat(Quat<T>& q) const
233{
234 Matrix33CalcCommon<T>::toQuat(q, *this);
235}
236
237template <typename T>
238inline Vector3<T> Matrix33<T>::getBase(s32 axis) const
239{
240 Vec3 o;
241 Matrix33CalcCommon<T>::getBase(o, *this, axis);
242 return o;
243}
244
245template <typename T>
246inline Vector3<T> Matrix33<T>::getRow(s32 axis) const
247{
248 Vec3 o;
249 Matrix33CalcCommon<T>::getRow(o, *this, axis);
250 return o;
251}
252
253template <typename T>
254inline void Matrix33<T>::getBase(Vec3& o, s32 axis) const
255{
256 Matrix33CalcCommon<T>::getBase(o, *this, axis);
257}
258
259template <typename T>
260inline void Matrix33<T>::getRow(Vec3& o, s32 row) const
261{
262 Matrix33CalcCommon<T>::getRow(o, *this, row);
263}
264
265template <typename T>
266inline void Matrix33<T>::setBase(s32 axis, const Vec3& v)
267{
268 Matrix33CalcCommon<T>::setBase(*this, axis, v);
269}
270
271template <typename T>
272inline void Matrix33<T>::setRow(s32 row, const Vec3& v)
273{
274 Matrix33CalcCommon<T>::setRow(*this, v, row);
275}
276
277template <typename T>
278inline Matrix34<T>::Matrix34(T a00, T a01, T a02, T a03, T a10, T a11, T a12, T a13, T a20, T a21,
279 T a22, T a23)
280{
281 this->m[0][0] = a00;
282 this->m[0][1] = a01;
283 this->m[0][2] = a02;
284 this->m[0][3] = a03;
285
286 this->m[1][0] = a10;
287 this->m[1][1] = a11;
288 this->m[1][2] = a12;
289 this->m[1][3] = a13;
290
291 this->m[2][0] = a20;
292 this->m[2][1] = a21;
293 this->m[2][2] = a22;
294 this->m[2][3] = a23;
295}
296
297template <typename T>
298inline Matrix34<T>::Matrix34(const Mtx33& mtx33, const Vec3& t)
299{
300 Matrix34CalcCommon<T>::copy(*this, mtx33, t);
301}
302
303template <typename T>
304inline Matrix34<T>::Matrix34(const Mtx44& mtx44)
305{
306 Matrix34CalcCommon<T>::copy(*this, mtx44);
307}
308
309template <typename T>
310inline T Matrix34<T>::operator()(s32 i, s32 j) const
311{
312 return this->m[i][j];
313}
314
315template <typename T>
316inline T& Matrix34<T>::operator()(s32 i, s32 j)
317{
318 return this->m[i][j];
319}
320
321template <typename T>
322inline Matrix34<T>& Matrix34<T>::operator=(const Self& n)
323{
324 Matrix34CalcCommon<T>::copy(*this, n);
325 return *this;
326}
327
328template <typename T>
329inline void Matrix34<T>::makeIdentity()
330{
331 Matrix34CalcCommon<T>::makeIdentity(*this);
332}
333
334template <typename T>
335inline void Matrix34<T>::makeZero()
336{
337 Matrix34CalcCommon<T>::makeZero(*this);
338}
339
340template <typename T>
341inline bool Matrix34<T>::invert()
342{
343 return setInverse(*this);
344}
345
346template <typename T>
347inline bool Matrix34<T>::invert33()
348{
349 return setInverse33(*this);
350}
351
352template <typename T>
353inline bool Matrix34<T>::invertTranspose()
354{
355 return setInverseTranspose(*this);
356}
357
358template <typename T>
359inline bool Matrix34<T>::setInverse(const Self& n)
360{
361 return Matrix34CalcCommon<T>::inverse(*this, n);
362}
363
364template <typename T>
365inline bool Matrix34<T>::setInverse33(const Self& n)
366{
367 return Matrix34CalcCommon<T>::inverse33(*this, n);
368}
369
370template <typename T>
371inline bool Matrix34<T>::setInverseTranspose(const Self& n)
372{
373 return Matrix34CalcCommon<T>::inverseTranspose(*this, n);
374}
375
376template <typename T>
377inline void Matrix34<T>::setMul(const Self& a, const Self& b)
378{
379 Matrix34CalcCommon<T>::multiply(*this, a, b);
380}
381
382template <typename T>
383inline void Matrix34<T>::setMul(const Mtx33& a, const Self& b)
384{
385 Matrix34CalcCommon<T>::multiply(*this, a, b);
386}
387
388template <typename T>
389inline void Matrix34<T>::setTranspose(const Self& n)
390{
391 Matrix34CalcCommon<T>::transposeTo(*this, n);
392}
393
394template <typename T>
395inline void Matrix34<T>::transpose()
396{
397 Matrix34CalcCommon<T>::transpose(*this);
398}
399
400template <typename T>
401inline void Matrix34<T>::fromQuat(const QuatT& q)
402{
403 Matrix34CalcCommon<T>::makeQ(*this, q);
404}
405
406template <typename T>
407inline void Matrix34<T>::makeQT(const QuatT& q, const Vec3& t)
408{
409 Matrix34CalcCommon<T>::makeQT(*this, q, t);
410}
411
412template <typename T>
413inline void Matrix34<T>::makeR(const Vec3& r)
414{
415 Matrix34CalcCommon<T>::makeR(*this, r);
416}
417
418template <typename T>
419inline void Matrix34<T>::makeRIdx(u32 xr, u32 yr, u32 zr)
420{
421 Matrix34CalcCommon<T>::makeRIdx(*this, xr, yr, zr);
422}
423
424template <typename T>
425inline void Matrix34<T>::makeRT(const Vec3& r, const Vec3& t)
426{
427 Matrix34CalcCommon<T>::makeRT(*this, r, t);
428}
429
430template <typename T>
431inline void Matrix34<T>::makeRTIdx(const Vector3<u32>& r, const Vec3& t)
432{
433 Matrix34CalcCommon<T>::makeRTIdx(*this, r, t);
434}
435
436template <typename T>
437inline void Matrix34<T>::makeRzxyIdx(u32 xr, u32 yr, u32 zr)
438{
439 Matrix34CalcCommon<T>::makeRzxyIdx(*this, xr, yr, zr);
440}
441
442template <typename T>
443inline void Matrix34<T>::makeRzxyTIdx(const Vector3<u32>& r, const Vec3& t)
444{
445 Matrix34CalcCommon<T>::makeRzxyTIdx(*this, r, t);
446}
447
448template <typename T>
449inline void Matrix34<T>::makeS(const Vec3& s)
450{
451 Matrix34CalcCommon<T>::makeS(*this, s);
452}
453
454template <typename T>
455inline void Matrix34<T>::makeS(T x, T y, T z)
456{
457 Vec3 s(x, y, z);
458 Matrix34CalcCommon<T>::makeS(*this, s);
459}
460
461template <typename T>
462inline void Matrix34<T>::makeSQT(const Vec3& s, const QuatT& q, const Vec3& t)
463{
464 Matrix34CalcCommon<T>::makeSQT(*this, s, q, t);
465}
466
467template <typename T>
468inline void Matrix34<T>::makeSR(const Vec3& s, const Vec3& r)
469{
470 Matrix34CalcCommon<T>::makeSR(*this, s, r);
471}
472
473template <typename T>
474inline void Matrix34<T>::makeSRIdx(const Vec3& s, const Vector3<u32>& r)
475{
476 Matrix34CalcCommon<T>::makeSRIdx(*this, s, r);
477}
478
479template <typename T>
480inline void Matrix34<T>::makeSRT(const Vec3& s, const Vec3& r, const Vec3& t)
481{
482 Matrix34CalcCommon<T>::makeSRT(*this, s, r, t);
483}
484
485template <typename T>
486inline void Matrix34<T>::makeSRTIdx(const Vec3& s, const Vector3<u32>& r, const Vec3& t)
487{
488 Matrix34CalcCommon<T>::makeSRTIdx(*this, s, r, t);
489}
490
491template <typename T>
492inline void Matrix34<T>::makeSRzxyIdx(const Vec3& s, const Vector3<u32>& r)
493{
494 Matrix34CalcCommon<T>::makeSRzxyIdx(*this, s, r);
495}
496
497template <typename T>
498inline void Matrix34<T>::makeSRzxyTIdx(const Vec3& s, const Vector3<u32>& r, const Vec3& t)
499{
500 Matrix34CalcCommon<T>::makeSRzxyTIdx(*this, s, r, t);
501}
502
503template <typename T>
504inline void Matrix34<T>::makeST(const Vec3& s, const Vec3& t)
505{
506 Matrix34CalcCommon<T>::makeST(*this, s, t);
507}
508
509template <typename T>
510inline void Matrix34<T>::makeT(const Vec3& t)
511{
512 Matrix34CalcCommon<T>::makeT(*this, t);
513}
514
515template <typename T>
516inline void Matrix34<T>::makeT(T x, T y, T z)
517{
518 Vec3 t(x, y, z);
519 Matrix34CalcCommon<T>::makeT(*this, t);
520}
521
522template <typename T>
523inline void Matrix34<T>::toQuat(QuatT& q) const
524{
525 Matrix34CalcCommon<T>::toQuat(q, *this);
526}
527
528template <typename T>
529inline Vector3<T> Matrix34<T>::getBase(s32 axis) const
530{
531 Vec3 o;
532 Matrix34CalcCommon<T>::getBase(o, *this, axis);
533 return o;
534}
535
536template <typename T>
537inline Vector4<T> Matrix34<T>::getRow(s32 axis) const
538{
539 Vec4 o;
540 Matrix34CalcCommon<T>::getRow(o, *this, axis);
541 return o;
542}
543
544template <typename T>
545inline Vector3<T> Matrix34<T>::getTranslation() const
546{
547 Vec3 o;
548 Matrix34CalcCommon<T>::getTranslation(o, *this);
549 return o;
550}
551
552template <typename T>
553inline Vector3<T> Matrix34<T>::getRotation() const
554{
555 Vec3 o;
556 Matrix34CalcCommon<T>::getRotation(o, *this);
557 return o;
558}
559
560template <typename T>
561inline void Matrix34<T>::getBase(Vec3& o, s32 axis) const
562{
563 Matrix34CalcCommon<T>::getBase(o, *this, axis);
564}
565
566template <typename T>
567inline void Matrix34<T>::getRow(Vec4& o, s32 row) const
568{
569 Matrix34CalcCommon<T>::getRow(o, *this, row);
570}
571
572template <typename T>
573inline void Matrix34<T>::getTranslation(Vec3& o) const
574{
575 Matrix34CalcCommon<T>::getTranslation(o, *this);
576}
577
578template <typename T>
579inline void Matrix34<T>::getRotation(Vec3& o) const
580{
581 Matrix34CalcCommon<T>::getRotation(o, *this);
582}
583
584template <typename T>
585inline void Matrix34<T>::scaleAllElements(T s)
586{
587 Matrix34CalcCommon<T>::scaleAllElements(*this, s);
588}
589
590template <typename T>
591inline void Matrix34<T>::scaleBases(T sx, T sy, T sz)
592{
593 Matrix34CalcCommon<T>::scaleBases(*this, sx, sy, sz);
594}
595
596template <typename T>
597inline void Matrix34<T>::setBase(s32 axis, const Vec3& v)
598{
599 Matrix34CalcCommon<T>::setBase(*this, axis, v);
600}
601
602template <typename T>
603inline void Matrix34<T>::setRow(s32 row, const Vec4& v)
604{
605 Matrix34CalcCommon<T>::setRow(*this, v, row);
606}
607
608template <typename T>
609inline void Matrix34<T>::setTranslation(const Vec3& t)
610{
611 Matrix34CalcCommon<T>::setTranslation(*this, t);
612}
613
614template <typename T>
615inline void Matrix34<T>::setTranslation(T x, T y, T z)
616{
617 Vec3 t(x, y, z);
618 Matrix34CalcCommon<T>::setTranslation(*this, t);
619}
620
621template <typename T>
622inline Matrix44<T>::Matrix44(T a00, T a01, T a02, T a03, T a10, T a11, T a12, T a13, T a20, T a21,
623 T a22, T a23, T a30, T a31, T a32, T a33)
624{
625 this->m[0][0] = a00;
626 this->m[0][1] = a01;
627 this->m[0][2] = a02;
628 this->m[0][3] = a03;
629
630 this->m[1][0] = a10;
631 this->m[1][1] = a11;
632 this->m[1][2] = a12;
633 this->m[1][3] = a13;
634
635 this->m[2][0] = a20;
636 this->m[2][1] = a21;
637 this->m[2][2] = a22;
638 this->m[2][3] = a23;
639
640 this->m[3][0] = a30;
641 this->m[3][1] = a31;
642 this->m[3][2] = a32;
643 this->m[3][3] = a33;
644}
645
646template <typename T>
647inline Matrix44<T>::Matrix44(const Mtx33& mtx33, const Vec3& t, const Vec4& vw)
648{
649 Matrix44CalcCommon<T>::copy(*this, mtx33, t, vw);
650}
651
652template <typename T>
653inline Matrix44<T>::Matrix44(const Mtx34& mtx34, const Vec4& vw)
654{
655 Matrix44CalcCommon<T>::copy(*this, mtx34, vw);
656}
657
658template <typename T>
659inline T Matrix44<T>::operator()(s32 i, s32 j) const
660{
661 return this->m[i][j];
662}
663
664template <typename T>
665inline T& Matrix44<T>::operator()(s32 i, s32 j)
666{
667 return this->m[i][j];
668}
669
670template <typename T>
671inline Matrix44<T>& Matrix44<T>::operator=(const Self& n)
672{
673 Matrix44CalcCommon<T>::copy(*this, n);
674 return *this;
675}
676
677template <typename T>
678inline void Matrix44<T>::makeIdentity()
679{
680 Matrix44CalcCommon<T>::makeIdentity();
681}
682
683template <typename T>
684inline void Matrix44<T>::makeZero()
685{
686 Matrix44CalcCommon<T>::makeZero();
687}
688
689template <typename T>
690inline void Matrix44<T>::setInverse(const Self& n)
691{
692 Matrix44CalcCommon<T>::inverse(*this, n);
693}
694
695template <typename T>
696inline void Matrix44<T>::setMul(const Self& a, const Self& b)
697{
698 Matrix44CalcCommon<T>::multiply(*this, a, b);
699}
700
701template <typename T>
702inline void Matrix44<T>::setMul(const Mtx34& a, const Self& b)
703{
704 Matrix44CalcCommon<T>::multiply(*this, a, b);
705}
706
707template <typename T>
708inline void Matrix44<T>::setMul(const Self& a, const Mtx34& b)
709{
710 Matrix44CalcCommon<T>::multiply(*this, a, b);
711}
712
713template <typename T>
714inline void Matrix44<T>::setTranspose(const Self& n)
715{
716 Matrix44CalcCommon<T>::transposeTo(*this, n);
717}
718
719template <typename T>
720inline void Matrix44<T>::transpose()
721{
722 Matrix44CalcCommon<T>::transpose(*this);
723}
724
725template <typename T>
726inline void Matrix44<T>::fromQuat(const Quat<T>& q)
727{
728 Matrix44CalcCommon<T>::makeQ(*this, q);
729}
730
731template <typename T>
732inline void Matrix44<T>::makeR(const Vec3& r)
733{
734 Matrix44CalcCommon<T>::makeR(*this, r);
735}
736
737template <typename T>
738inline void Matrix44<T>::makeRIdx(u32 xr, u32 yr, u32 zr)
739{
740 Matrix44CalcCommon<T>::makeRIdx(*this, xr, yr, zr);
741}
742
743template <typename T>
744inline void Matrix44<T>::makeRzxyIdx(u32 xr, u32 yr, u32 zr)
745{
746 Matrix44CalcCommon<T>::makeRzxyIdx(*this, xr, yr, zr);
747}
748
749template <typename T>
750inline void Matrix44<T>::toQuat(Quat<T>& q) const
751{
752 Matrix44CalcCommon<T>::toQuat(q, *this);
753}
754
755template <typename T>
756inline Vector4<T> Matrix44<T>::getCol(s32 axis) const
757{
758 Vec4 o;
759 Matrix44CalcCommon<T>::getCol(o, *this, axis);
760 return o;
761}
762
763template <typename T>
764inline Vector4<T> Matrix44<T>::getRow(s32 axis) const
765{
766 Vec4 o;
767 Matrix44CalcCommon<T>::getRow(o, *this, axis);
768 return o;
769}
770
771template <typename T>
772inline void Matrix44<T>::getCol(Vec4& o, s32 axis) const
773{
774 Matrix44CalcCommon<T>::getCol(o, *this, axis);
775}
776
777template <typename T>
778inline void Matrix44<T>::getRow(Vec4& o, s32 row) const
779{
780 Matrix44CalcCommon<T>::getRow(o, *this, row);
781}
782
783template <typename T>
784inline void Matrix44<T>::scaleAllElements(T s)
785{
786 Matrix44CalcCommon<T>::scaleAllElements(*this, s);
787}
788
789template <typename T>
790inline void Matrix44<T>::scaleBases(T sx, T sy, T sz, T sw)
791{
792 Matrix44CalcCommon<T>::scaleBases(*this, sx, sy, sz, sw);
793}
794
795template <typename T>
796inline void Matrix44<T>::setCol(s32 axis, const Vec4& v)
797{
798 Matrix44CalcCommon<T>::setCol(*this, axis, v);
799}
800
801template <typename T>
802inline void Matrix44<T>::setRow(s32 row, const Vec4& v)
803{
804 Matrix44CalcCommon<T>::setRow(*this, row, v);
805}
806
807template <typename T>
808inline bool operator==(const Matrix34<T>& lhs, const Matrix34<T>& rhs)
809{
810 return lhs.a == rhs.a;
811}
812
813template <typename T>
814inline bool operator!=(const Matrix34<T>& lhs, const Matrix34<T>& rhs)
815{
816 return lhs.a != rhs.a;
817}
818
819} // namespace sead
820