t
Loading...
Searching...
No Matches
Matrix4x4.hpp
1#include "EulerRotation.hpp"
2#include "Matrix3x3.hpp"
3#include "Vector3.hpp"
4#include "Vector4.hpp"
5#include <array>
6#include <cmath>
7
8#ifndef MATRIX4X4_HPP
9#define MATRIX4X4_HPP
10
11namespace t {
12
13#define n11 elements[0]
14#define n12 elements[1]
15#define n13 elements[2]
16#define n14 elements[3]
17#define n21 elements[4]
18#define n22 elements[5]
19#define n23 elements[6]
20#define n24 elements[7]
21#define n31 elements[8]
22#define n32 elements[9]
23#define n33 elements[10]
24#define n34 elements[11]
25#define n41 elements[12]
26#define n42 elements[13]
27#define n43 elements[14]
28#define n44 elements[15]
29
35class Matrix4x4 {
36public:
37 std::array<double, 16> elements;
46 // clang-format off
47 return Matrix4x4(1, 0, 0, 0,
48 0, 1, 0, 0,
49 0, 0, 1, 0,
50 0, 0, 0, 1);
51 // clang-format on
52 }
53
59 static Matrix4x4 zero() {
60 // clang-format off
61 return Matrix4x4(0, 0, 0, 0,
62 0, 0, 0, 0,
63 0, 0, 0, 0,
64 0, 0, 0, 0);
65 // clang-format on
66 }
67
79 static Matrix4x4 fromTranslation(const Vector3 &distance) {
80 // clang-format off
81 return Matrix4x4(1, 0, 0, distance.x,
82 0, 1, 0, distance.y,
83 0, 0, 1, distance.z,
84 0, 0, 0, 1);
85 // clang-format on
86 }
87
99 static Matrix4x4 fromRotation(const EulerRotation &angle) {
100 // clang-format off
101 auto rotationX = Matrix4x4(1, 0, 0, 0,
102 0, std::cos(angle.x), -std::sin(angle.x), 0,
103 0, std::sin(angle.x), std::cos(angle.x), 0,
104 0, 0, 0, 1);
105
106 auto rotationY = Matrix4x4(std::cos(angle.y), 0, std::sin(angle.y), 0,
107 0, 1, 0, 0,
108 -std::sin(angle.y), 0, std::cos(angle.y), 0,
109 0, 0, 0, 1);
110
111 auto rotationZ = Matrix4x4(std::cos(angle.z), -std::sin(angle.z), 0, 0,
112 std::sin(angle.z), std::cos(angle.z), 0, 0,
113 0, 0, 1, 0,
114 0, 0, 0, 1);
115 // clang-format on
116
117 auto const &firstRotation =
118 getRotationMatrix(rotationX, rotationY, rotationZ, angle.order, 0);
119 auto const &secondRotation =
120 getRotationMatrix(rotationX, rotationY, rotationZ, angle.order, 1);
121 auto const &thirdRotation =
122 getRotationMatrix(rotationX, rotationY, rotationZ, angle.order, 2);
123
124 return thirdRotation * secondRotation * firstRotation;
125 }
126
133 static Matrix4x4 fromScale(const Vector3 &scaleFactor) {
134 // clang-format off
135 return Matrix4x4(scaleFactor.x, 0, 0, 0,
136 0, scaleFactor.y, 0, 0,
137 0, 0, scaleFactor.z, 0,
138 0, 0, 0, 1);
139 // clang-format on
140 }
141
162 Matrix4x4(double _n11, double _n12, double _n13, double _n14, double _n21,
163 double _n22, double _n23, double _n24, double _n31, double _n32,
164 double _n33, double _n34, double _n41, double _n42, double _n43,
165 double _n44)
166 : elements({_n11, _n12, _n13, _n14, _n21, _n22, _n23, _n24, _n31, _n32,
167 _n33, _n34, _n41, _n42, _n43, _n44}) {}
168
174 Matrix4x4 clone() const {
175 // clang-format off
176 return Matrix4x4(n11, n12, n13, n14,
177 n21, n22, n23, n24,
178 n31, n32, n33, n34,
179 n41, n42, n43, n44);
180 // clang-format on
181 }
182
189 Matrix4x4 &copy(const Matrix4x4 &source) {
190 for (auto i = 0; i < 16; ++i) {
191 elements[i] = source.elements[i];
192 }
193
194 return *this;
195 }
196
218 Matrix4x4 &set(double _n11, double _n12, double _n13, double _n14,
219 double _n21, double _n22, double _n23, double _n24,
220 double _n31, double _n32, double _n33, double _n34,
221 double _n41, double _n42, double _n43, double _n44) {
222 n11 = _n11;
223 n12 = _n12;
224 n13 = _n13;
225 n14 = _n14;
226 n21 = _n21;
227 n22 = _n22;
228 n23 = _n23;
229 n24 = _n24;
230 n31 = _n31;
231 n32 = _n32;
232 n33 = _n33;
233 n34 = _n34;
234 n41 = _n41;
235 n42 = _n42;
236 n43 = _n43;
237 n44 = _n44;
238
239 return *this;
240 }
241
252 double get(int row, int column) const {
253 return elements.at(row * 4 + column);
254 }
255
265 Matrix4x4 &set(int row, int column, int value) {
266 elements.at(row * 4 + column) = value;
267 return *this;
268 }
269
276 // clang-format off
277 return set(1, 0, 0, 0,
278 0, 1, 0, 0,
279 0, 0, 1, 0,
280 0, 0, 0, 1);
281 // clang-format on
282 }
283
290 double determinant() const {
291 // clang-format off
292 return
293 n14 * n23 * n32 * n41 - n13 * n24 * n32 * n41 - n14 * n22 * n33 * n41 + n12 * n24 * n33 * n41 +
294 n13 * n22 * n34 * n41 - n12 * n23 * n34 * n41 - n14 * n23 * n31 * n42 + n13 * n24 * n31 * n42 +
295 n14 * n21 * n33 * n42 - n11 * n24 * n33 * n42 - n13 * n21 * n34 * n42 + n11 * n23 * n34 * n42 +
296 n14 * n22 * n31 * n43 - n12 * n24 * n31 * n43 - n14 * n21 * n32 * n43 + n11 * n24 * n32 * n43 +
297 n12 * n21 * n34 * n43 - n11 * n22 * n34 * n43 - n13 * n22 * n31 * n44 + n12 * n23 * n31 * n44 +
298 n13 * n21 * n32 * n44 - n11 * n23 * n32 * n44 - n12 * n21 * n33 * n44 + n11 * n22 * n33 * n44;
299 // clang-format on
300 }
301
311 // clang-format off
312 return Matrix4x4(n11, n21, n31, n41,
313 n12, n22, n32, n42,
314 n13, n23, n33, n43,
315 n14, n24, n34, n44);
316 // clang-format on
317 }
318
332 auto det = determinant();
333
334 if (det == 0) {
335 return Matrix4x4::zero();
336 }
337
338 // clang-format off
339 auto adjoint = Matrix4x4(
340 n23 * n34 * n42 - n24 * n33 * n42 + n24 * n32 * n43 - n22 * n34 * n43 - n23 * n32 * n44 + n22 * n33 * n44,
341 n14 * n33 * n42 - n13 * n34 * n42 - n14 * n32 * n43 + n12 * n34 * n43 + n13 * n32 * n44 - n12 * n33 * n44,
342 n13 * n24 * n42 - n14 * n23 * n42 + n14 * n22 * n43 - n12 * n24 * n43 - n13 * n22 * n44 + n12 * n23 * n44,
343 n14 * n23 * n32 - n13 * n24 * n32 - n14 * n22 * n33 + n12 * n24 * n33 + n13 * n22 * n34 - n12 * n23 * n34,
344 n24 * n33 * n41 - n23 * n34 * n41 - n24 * n31 * n43 + n21 * n34 * n43 + n23 * n31 * n44 - n21 * n33 * n44,
345 n13 * n34 * n41 - n14 * n33 * n41 + n14 * n31 * n43 - n11 * n34 * n43 - n13 * n31 * n44 + n11 * n33 * n44,
346 n14 * n23 * n41 - n13 * n24 * n41 - n14 * n21 * n43 + n11 * n24 * n43 + n13 * n21 * n44 - n11 * n23 * n44,
347 n13 * n24 * n31 - n14 * n23 * n31 + n14 * n21 * n33 - n11 * n24 * n33 - n13 * n21 * n34 + n11 * n23 * n34,
348 n22 * n34 * n41 - n24 * n32 * n41 + n24 * n31 * n42 - n21 * n34 * n42 - n22 * n31 * n44 + n21 * n32 * n44,
349 n14 * n32 * n41 - n12 * n34 * n41 - n14 * n31 * n42 + n11 * n34 * n42 + n12 * n31 * n44 - n11 * n32 * n44,
350 n12 * n24 * n41 - n14 * n22 * n41 + n14 * n21 * n42 - n11 * n24 * n42 - n12 * n21 * n44 + n11 * n22 * n44,
351 n14 * n22 * n31 - n12 * n24 * n31 - n14 * n21 * n32 + n11 * n24 * n32 + n12 * n21 * n34 - n11 * n22 * n34,
352 n23 * n32 * n41 - n22 * n33 * n41 - n23 * n31 * n42 + n21 * n33 * n42 + n22 * n31 * n43 - n21 * n32 * n43,
353 n12 * n33 * n41 - n13 * n32 * n41 + n13 * n31 * n42 - n11 * n33 * n42 - n12 * n31 * n43 + n11 * n32 * n43,
354 n13 * n22 * n41 - n12 * n23 * n41 - n13 * n21 * n42 + n11 * n23 * n42 + n12 * n21 * n43 - n11 * n22 * n43,
355 n12 * n23 * n31 - n13 * n22 * n31 + n13 * n21 * n32 - n11 * n23 * n32 - n12 * n21 * n33 + n11 * n22 * n33
356 );
357 // clang-format on
358
359 return (1.0 / det) * adjoint;
360 }
361
372 return Matrix3x3(n11, n12, n13, n21, n22, n23, n31, n32, n33);
373 }
374
387 double operator[](std::size_t index) const { return elements.at(index); }
388
396 for (auto i = 0; i < 16; ++i) {
397 elements[i] += m.elements[i];
398 }
399
400 return *this;
401 }
402
410 for (auto &element : elements) {
411 element += s;
412 }
413
414 return *this;
415 }
416
424 for (auto i = 0; i < 16; ++i) {
425 elements[i] -= m.elements[i];
426 }
427
428 return *this;
429 }
430
438 for (auto &element : elements) {
439 element -= s;
440 }
441
442 return *this;
443 }
444
455 Matrix4x4 &operator*=(const Matrix4x4 &m) { return this->copy(*this * m); }
456
464 for (auto &element : elements) {
465 element *= s;
466 }
467
468 return *this;
469 }
470
479 for (auto i = 0; i < 16; ++i) {
480 elements[i] /= m.elements[i];
481 }
482
483 return *this;
484 }
485
493 for (auto &element : elements) {
494 element /= s;
495 }
496
497 return *this;
498 }
499
507 friend bool operator==(const Matrix4x4 &a, const Matrix4x4 &b) = default;
508
516 friend Matrix4x4 operator+(const Matrix4x4 &a, const Matrix4x4 &b) {
517 // clang-format off
518 return Matrix4x4(a.n11 + b.n11, a.n12 + b.n12, a.n13 + b.n13, a.n14 + b.n14,
519 a.n21 + b.n21, a.n22 + b.n22, a.n23 + b.n23, a.n24 + b.n24,
520 a.n31 + b.n31, a.n32 + b.n32, a.n33 + b.n33, a.n34 + b.n34,
521 a.n41 + b.n41, a.n42 + b.n42, a.n43 + b.n43, a.n44 + b.n44);
522 // clang-format on
523 }
524
532 friend Matrix4x4 operator+(const Matrix4x4 &a, double s) {
533 // clang-format off
534 return Matrix4x4(a.n11 + s, a.n12 + s, a.n13 + s, a.n14 + s,
535 a.n21 + s, a.n22 + s, a.n23 + s, a.n24 + s,
536 a.n31 + s, a.n32 + s, a.n33 + s, a.n34 + s,
537 a.n41 + s, a.n42 + s, a.n43 + s, a.n44 + s);
538 // clang-format on
539 }
540
548 friend Matrix4x4 operator+(double s, const Matrix4x4 &a) { return a + s; }
549
557 friend Matrix4x4 operator-(const Matrix4x4 &a, const Matrix4x4 &b) {
558 // clang-format off
559 return Matrix4x4(a.n11 - b.n11, a.n12 - b.n12, a.n13 - b.n13, a.n14 - b.n14,
560 a.n21 - b.n21, a.n22 - b.n22, a.n23 - b.n23, a.n24 - b.n24,
561 a.n31 - b.n31, a.n32 - b.n32, a.n33 - b.n33, a.n34 - b.n34,
562 a.n41 - b.n41, a.n42 - b.n42, a.n43 - b.n43, a.n44 - b.n44);
563 // clang-format on
564 }
565
574 friend Matrix4x4 operator-(const Matrix4x4 &a, double s) {
575 // clang-format off
576 return Matrix4x4(a.n11 - s, a.n12 - s, a.n13 - s, a.n14 - s,
577 a.n21 - s, a.n22 - s, a.n23 - s, a.n24 - s,
578 a.n31 - s, a.n32 - s, a.n33 - s, a.n34 - s,
579 a.n41 - s, a.n42 - s, a.n43 - s, a.n44 - s);
580 // clang-format on
581 }
582
592 friend Matrix4x4 operator-(double s, const Matrix4x4 &a) {
593 // clang-format off
594 return Matrix4x4(s - a.n11, s - a.n12, s - a.n13, s - a.n14,
595 s - a.n21, s - a.n22, s - a.n23, s - a.n24,
596 s - a.n31, s - a.n32, s - a.n33, s - a.n34,
597 s - a.n41, s - a.n42, s - a.n43, s - a.n44);
598 // clang-format on
599 }
600
611 friend Matrix4x4 operator*(const Matrix4x4 &a, const Matrix4x4 &b) {
612 return Matrix4x4(
613 a.n11 * b.n11 + a.n12 * b.n21 + a.n13 * b.n31 + a.n14 * b.n41,
614 a.n11 * b.n12 + a.n12 * b.n22 + a.n13 * b.n32 + a.n14 * b.n42,
615 a.n11 * b.n13 + a.n12 * b.n23 + a.n13 * b.n33 + a.n14 * b.n43,
616 a.n11 * b.n14 + a.n12 * b.n24 + a.n13 * b.n34 + a.n14 * b.n44,
617 a.n21 * b.n11 + a.n22 * b.n21 + a.n23 * b.n31 + a.n24 * b.n41,
618 a.n21 * b.n12 + a.n22 * b.n22 + a.n23 * b.n32 + a.n24 * b.n42,
619 a.n21 * b.n13 + a.n22 * b.n23 + a.n23 * b.n33 + a.n24 * b.n43,
620 a.n21 * b.n14 + a.n22 * b.n24 + a.n23 * b.n34 + a.n24 * b.n44,
621 a.n31 * b.n11 + a.n32 * b.n21 + a.n33 * b.n31 + a.n34 * b.n41,
622 a.n31 * b.n12 + a.n32 * b.n22 + a.n33 * b.n32 + a.n34 * b.n42,
623 a.n31 * b.n13 + a.n32 * b.n23 + a.n33 * b.n33 + a.n34 * b.n43,
624 a.n31 * b.n14 + a.n32 * b.n24 + a.n33 * b.n34 + a.n34 * b.n44,
625 a.n41 * b.n11 + a.n42 * b.n21 + a.n43 * b.n31 + a.n44 * b.n41,
626 a.n41 * b.n12 + a.n42 * b.n22 + a.n43 * b.n32 + a.n44 * b.n42,
627 a.n41 * b.n13 + a.n42 * b.n23 + a.n43 * b.n33 + a.n44 * b.n43,
628 a.n41 * b.n14 + a.n42 * b.n24 + a.n43 * b.n34 + a.n44 * b.n44);
629 }
630
639 friend Matrix4x4 operator*(const Matrix4x4 &a, double s) {
640 // clang-format off
641 return Matrix4x4(a.n11 * s, a.n12 * s, a.n13 * s, a.n14 * s,
642 a.n21 * s, a.n22 * s, a.n23 * s, a.n24 * s,
643 a.n31 * s, a.n32 * s, a.n33 * s, a.n34 * s,
644 a.n41 * s, a.n42 * s, a.n43 * s, a.n44 * s);
645 // clang-format on
646 }
647
656 friend Matrix4x4 operator*(double s, const Matrix4x4 &a) { return a * s; }
657
665 friend Vector4 operator*(const Matrix4x4 &a, const Vector4 &v) {
666 return Vector4(a.n11 * v.x + a.n12 * v.y + a.n13 * v.z + a.n14 * v.w,
667 a.n21 * v.x + a.n22 * v.y + a.n23 * v.z + a.n24 * v.w,
668 a.n31 * v.x + a.n32 * v.y + a.n33 * v.z + a.n34 * v.w,
669 a.n41 * v.x + a.n42 * v.y + a.n43 * v.z + a.n44 * v.w);
670 }
671
679 friend Matrix4x4 operator/(const Matrix4x4 &a, const Matrix4x4 &b) {
680 // clang-format off
681 return Matrix4x4(a.n11 / b.n11, a.n12 / b.n12, a.n13 / b.n13, a.n14 / b.n14,
682 a.n21 / b.n21, a.n22 / b.n22, a.n23 / b.n23, a.n24 / b.n24,
683 a.n31 / b.n31, a.n32 / b.n32, a.n33 / b.n33, a.n34 / b.n34,
684 a.n41 / b.n41, a.n42 / b.n42, a.n43 / b.n43, a.n44 / b.n44);
685 // clang-format on
686 }
687
695 friend Matrix4x4 operator/(const Matrix4x4 &a, double s) {
696 // clang-format off
697 return Matrix4x4(a.n11 / s, a.n12 / s, a.n13 / s, a.n14 / s,
698 a.n21 / s, a.n22 / s, a.n23 / s, a.n24 / s,
699 a.n31 / s, a.n32 / s, a.n33 / s, a.n34 / s,
700 a.n41 / s, a.n42 / s, a.n43 / s, a.n44 / s);
701 // clang-format on
702 }
703
712 friend Matrix4x4 operator/(double s, const Matrix4x4 &a) {
713 // clang-format off
714 return Matrix4x4(s / a.n11, s / a.n12, s / a.n13, s / a.n14,
715 s / a.n21, s / a.n22, s / a.n23, s / a.n24,
716 s / a.n31, s / a.n32, s / a.n33, s / a.n34,
717 s / a.n41, s / a.n42, s / a.n43, s / a.n44);
718 // clang-format on
719 }
720
721private:
722 static Matrix4x4 &getRotationMatrix(Matrix4x4 &rotationX,
723 Matrix4x4 &rotationY,
724 Matrix4x4 &rotationZ,
725 EulerRotationOrder order, int index) {
726 switch (index) {
727 using enum EulerRotationOrder;
728 case 0:
729 switch (order) {
730 case Xyz:
731 case Xzy:
732 return rotationX;
733
734 case Yxz:
735 case Yzx:
736 return rotationY;
737
738 case Zxy:
739 case Zyx:
740 return rotationZ;
741 }
742
743 case 1:
744 switch (order) {
745 case Yxz:
746 case Zxy:
747 return rotationX;
748
749 case Xyz:
750 case Zyx:
751 return rotationY;
752
753 case Xzy:
754 case Yzx:
755 return rotationZ;
756 }
757
758 case 2:
759 switch (order) {
760 case Yzx:
761 case Zyx:
762 return rotationX;
763
764 case Xzy:
765 case Zxy:
766 return rotationY;
767
768 case Xyz:
769 case Yxz:
770 return rotationZ;
771 }
772
773 default:
774 return rotationX;
775 }
776 }
777};
778
779#undef n11
780#undef n12
781#undef n13
782#undef n14
783#undef n21
784#undef n22
785#undef n23
786#undef n24
787#undef n31
788#undef n32
789#undef n33
790#undef n34
791#undef n41
792#undef n42
793#undef n43
794#undef n44
795
796} // namespace t
797
798#endif // MATRIX4X4_HPP
The Euler rotation class.
Definition EulerRotation.hpp:17
double x
The amount of rotation about the local X axis in radians.
Definition EulerRotation.hpp:19
double y
The amount of rotation about the local Y axis in radians.
Definition EulerRotation.hpp:20
double z
The amount of rotation about the local Z axis in radians.
Definition EulerRotation.hpp:21
EulerRotationOrder order
The order to perform the rotations around individual axes.
Definition EulerRotation.hpp:23
The matrix class.
Definition Matrix3x3.hpp:24
The matrix class.
Definition Matrix4x4.hpp:35
Matrix4x4 & operator/=(const Matrix4x4 &m)
Divides the elements of this matrix by the corresponding elements of the specified matrix.
Definition Matrix4x4.hpp:478
Matrix4x4 inverse() const
Returns the inverse of this matrix or the zero matrix if this matrix does not have an inverse.
Definition Matrix4x4.hpp:331
Matrix4x4 & operator+=(double s)
Adds the specified constant to all elements in this matrix.
Definition Matrix4x4.hpp:409
Matrix4x4 transpose() const
Returns the transpose of this matrix.
Definition Matrix4x4.hpp:310
Matrix4x4 & operator*=(double s)
Multiplies the elements of this matrix with the specified constant.
Definition Matrix4x4.hpp:463
Matrix4x4 & set(int row, int column, int value)
Sets the element at the specified row and column of this matrix to the specified value.
Definition Matrix4x4.hpp:265
double get(int row, int column) const
Gets the element at the specified row and column of this matrix with bounds checking.
Definition Matrix4x4.hpp:252
friend Matrix4x4 operator-(double s, const Matrix4x4 &a)
Substracts a matrix from a constant matrix.
Definition Matrix4x4.hpp:592
static Matrix4x4 fromTranslation(const Vector3 &distance)
Returns a translation matrix for the specified translation for post-multiplication ( where is the h...
Definition Matrix4x4.hpp:79
Matrix3x3 topLeft3x3Matrix() const
Returns the top-left matrix of this matrix.
Definition Matrix4x4.hpp:371
Matrix4x4(double _n11, double _n12, double _n13, double _n14, double _n21, double _n22, double _n23, double _n24, double _n31, double _n32, double _n33, double _n34, double _n41, double _n42, double _n43, double _n44)
Creates a new matrix with the specified elements.
Definition Matrix4x4.hpp:162
friend Matrix4x4 operator/(const Matrix4x4 &a, double s)
Divides all elements of a matrix by a constant.
Definition Matrix4x4.hpp:695
friend Matrix4x4 operator*(double s, const Matrix4x4 &a)
Multiplies all elements of a matrix with a constant.
Definition Matrix4x4.hpp:656
double determinant() const
Returns the determinant of this matrix.
Definition Matrix4x4.hpp:290
static Matrix4x4 identity()
Returns a identity matrix.
Definition Matrix4x4.hpp:45
double operator[](std::size_t index) const
Returns the element at the specified index of this matrix without bounds checking and assuming row-ma...
Definition Matrix4x4.hpp:387
friend Matrix4x4 operator/(const Matrix4x4 &a, const Matrix4x4 &b)
Returns the element-wise division of two matrices.
Definition Matrix4x4.hpp:679
static Matrix4x4 fromRotation(const EulerRotation &angle)
Returns a rotation matrix for the specified rotation for post-multiplication ( where is the homogen...
Definition Matrix4x4.hpp:99
static Matrix4x4 fromScale(const Vector3 &scaleFactor)
Returns a scale matrix for the specified scale factor.
Definition Matrix4x4.hpp:133
Matrix4x4 & operator-=(double s)
Substracts the specified constant from all elements in this matrix.
Definition Matrix4x4.hpp:437
Matrix4x4 & reset()
Resets this matrix to the identity matrix.
Definition Matrix4x4.hpp:275
Matrix4x4 & operator/=(double s)
Divides the elements of this matrix with the specified constant.
Definition Matrix4x4.hpp:492
Matrix4x4 & operator*=(const Matrix4x4 &m)
Multiplies this matrix with another matrix and copies the result into this instance.
Definition Matrix4x4.hpp:455
friend Matrix4x4 operator-(const Matrix4x4 &a, double s)
Substracts a constant from all elements of a matrix.
Definition Matrix4x4.hpp:574
Matrix4x4 & operator-=(const Matrix4x4 &m)
Substracts the specified matrix from this matrix.
Definition Matrix4x4.hpp:423
Matrix4x4 & set(double _n11, double _n12, double _n13, double _n14, double _n21, double _n22, double _n23, double _n24, double _n31, double _n32, double _n33, double _n34, double _n41, double _n42, double _n43, double _n44)
Sets the elements of this matrix.
Definition Matrix4x4.hpp:218
Matrix4x4 clone() const
Returns a copy of this matrix.
Definition Matrix4x4.hpp:174
static Matrix4x4 zero()
Returns a zero matrix.
Definition Matrix4x4.hpp:59
friend Vector4 operator*(const Matrix4x4 &a, const Vector4 &v)
Multiplies a matrix with a four-dimensional vector.
Definition Matrix4x4.hpp:665
Matrix4x4 & operator+=(const Matrix4x4 &m)
Adds the specified matrix to this matrix.
Definition Matrix4x4.hpp:395
friend bool operator==(const Matrix4x4 &a, const Matrix4x4 &b)=default
Returns whether two matrices are equal.
friend Matrix4x4 operator*(const Matrix4x4 &a, const Matrix4x4 &b)
Multiplies two matrices.
Definition Matrix4x4.hpp:611
friend Matrix4x4 operator+(const Matrix4x4 &a, const Matrix4x4 &b)
Adds two matrices.
Definition Matrix4x4.hpp:516
Matrix4x4 & copy(const Matrix4x4 &source)
Copies the elements of another matrix into this matrix.
Definition Matrix4x4.hpp:189
friend Matrix4x4 operator+(const Matrix4x4 &a, double s)
Adds a constant to all elements of a matrix.
Definition Matrix4x4.hpp:532
friend Matrix4x4 operator*(const Matrix4x4 &a, double s)
Multiplies all elements of a matrix with a constant.
Definition Matrix4x4.hpp:639
friend Matrix4x4 operator/(double s, const Matrix4x4 &a)
Returns the element-wise division of a constant matrix and a matrix.
Definition Matrix4x4.hpp:712
friend Matrix4x4 operator-(const Matrix4x4 &a, const Matrix4x4 &b)
Substracts 2 matrices.
Definition Matrix4x4.hpp:557
friend Matrix4x4 operator+(double s, const Matrix4x4 &a)
Adds a constant to all elements of a matrix.
Definition Matrix4x4.hpp:548
std::array< double, 16 > elements
The array containing the elements of this matrix in row-major order.
Definition Matrix4x4.hpp:37
The 3D vector class.
Definition Vector3.hpp:20
double z
The z component of this 3D vector.
Definition Vector3.hpp:24
double y
The y component of this 3D vector.
Definition Vector3.hpp:23
double x
The x component of this 3D vector.
Definition Vector3.hpp:22
The 4D vector class.
Definition Vector4.hpp:20
The t software 3D graphics library namespace.
Definition algorithms.hpp:12
EulerRotationOrder
The Euler rotation order.
Definition constants.hpp:19