48 for (
int i = 0; i < 4; ++i) {
49 for (
int j = 0; j < 4; ++j) {
50 m[i][j] = (i == j) ? 1.0f : 0.0f;
61 m[0][0] = 1;
m[0][1] = 0;
m[0][2] = 0;
m[0][3] = 0;
62 m[1][0] = 0;
m[1][1] = 1;
m[1][2] = 0;
m[1][3] = 0;
63 m[2][0] = 0;
m[2][1] = 0;
m[2][2] = 1;
m[2][3] = 0;
64 m[3][0] = 0;
m[3][1] = 0;
m[3][2] = 0;
m[3][3] = 1;
90 Matrix4x4(
float a11,
float a12,
float a13,
float a14,
91 float a21,
float a22,
float a23,
float a24,
92 float a31,
float a32,
float a33,
float a34,
93 float a41,
float a42,
float a43,
float a44) {
94 m[0][0] = a11;
m[0][1] = a12;
m[0][2] = a13;
m[0][3] = a14;
95 m[1][0] = a21;
m[1][1] = a22;
m[1][2] = a23;
m[1][3] = a24;
96 m[2][0] = a31;
m[2][1] = a32;
m[2][2] = a33;
m[2][3] = a34;
97 m[3][0] = a41;
m[3][1] = a42;
m[3][2] = a43;
m[3][3] = a44;
102 for (
int i = 0; i < 4; ++i) {
103 for (
int j = 0; j < 4; ++j) {
104 m[i][j] = other.
m[i][j];
117 m[0][0] + other.
m[0][0],
m[0][1] + other.
m[0][1],
m[0][2] + other.
m[0][2],
m[0][3] + other.
m[0][3],
118 m[1][0] + other.
m[1][0],
m[1][1] + other.
m[1][1],
m[1][2] + other.
m[1][2],
m[1][3] + other.
m[1][3],
119 m[2][0] + other.
m[2][0],
m[2][1] + other.
m[2][1],
m[2][2] + other.
m[2][2],
m[2][3] + other.
m[2][3],
120 m[3][0] + other.
m[3][0],
m[3][1] + other.
m[3][1],
m[3][2] + other.
m[3][2],
m[3][3] + other.
m[3][3]
132 m[0][0] - other.
m[0][0],
m[0][1] - other.
m[0][1],
m[0][2] - other.
m[0][2],
m[0][3] - other.
m[0][3],
133 m[1][0] - other.
m[1][0],
m[1][1] - other.
m[1][1],
m[1][2] - other.
m[1][2],
m[1][3] - other.
m[1][3],
134 m[2][0] - other.
m[2][0],
m[2][1] - other.
m[2][1],
m[2][2] - other.
m[2][2],
m[2][3] - other.
m[2][3],
135 m[3][0] - other.
m[3][0],
m[3][1] - other.
m[3][1],
m[3][2] - other.
m[3][2],
m[3][3] - other.
m[3][3]
147 m[0][0] * other.
m[0][0] +
m[0][1] * other.
m[1][0] +
m[0][2] * other.
m[2][0] +
m[0][3] * other.
m[3][0],
148 m[0][0] * other.
m[0][1] +
m[0][1] * other.
m[1][1] +
m[0][2] * other.
m[2][1] +
m[0][3] * other.
m[3][1],
149 m[0][0] * other.
m[0][2] +
m[0][1] * other.
m[1][2] +
m[0][2] * other.
m[2][2] +
m[0][3] * other.
m[3][2],
150 m[0][0] * other.
m[0][3] +
m[0][1] * other.
m[1][3] +
m[0][2] * other.
m[2][3] +
m[0][3] * other.
m[3][3],
152 m[1][0] * other.
m[0][0] +
m[1][1] * other.
m[1][0] +
m[1][2] * other.
m[2][0] +
m[1][3] * other.
m[3][0],
153 m[1][0] * other.
m[0][1] +
m[1][1] * other.
m[1][1] +
m[1][2] * other.
m[2][1] +
m[1][3] * other.
m[3][1],
154 m[1][0] * other.
m[0][2] +
m[1][1] * other.
m[1][2] +
m[1][2] * other.
m[2][2] +
m[1][3] * other.
m[3][2],
155 m[1][0] * other.
m[0][3] +
m[1][1] * other.
m[1][3] +
m[1][2] * other.
m[2][3] +
m[1][3] * other.
m[3][3],
157 m[2][0] * other.
m[0][0] +
m[2][1] * other.
m[1][0] +
m[2][2] * other.
m[2][0] +
m[2][3] * other.
m[3][0],
158 m[2][0] * other.
m[0][1] +
m[2][1] * other.
m[1][1] +
m[2][2] * other.
m[2][1] +
m[2][3] * other.
m[3][1],
159 m[2][0] * other.
m[0][2] +
m[2][1] * other.
m[1][2] +
m[2][2] * other.
m[2][2] +
m[2][3] * other.
m[3][2],
160 m[2][0] * other.
m[0][3] +
m[2][1] * other.
m[1][3] +
m[2][2] * other.
m[2][3] +
m[2][3] * other.
m[3][3],
162 m[3][0] * other.
m[0][0] +
m[3][1] * other.
m[1][0] +
m[3][2] * other.
m[2][0] +
m[3][3] * other.
m[3][0],
163 m[3][0] * other.
m[0][1] +
m[3][1] * other.
m[1][1] +
m[3][2] * other.
m[2][1] +
m[3][3] * other.
m[3][1],
164 m[3][0] * other.
m[0][2] +
m[3][1] * other.
m[1][2] +
m[3][2] * other.
m[2][2] +
m[3][3] * other.
m[3][2],
165 m[3][0] * other.
m[0][3] +
m[3][1] * other.
m[1][3] +
m[3][2] * other.
m[2][3] +
m[3][3] * other.
m[3][3]
177 m[1][1] * (
m[2][2] *
m[3][3] -
m[2][3] *
m[3][2]) -
178 m[1][2] * (
m[2][1] *
m[3][3] -
m[2][3] *
m[3][1]) +
179 m[1][3] * (
m[2][1] *
m[3][2] -
m[2][2] *
m[3][1])
182 m[1][0] * (
m[2][2] *
m[3][3] -
m[2][3] *
m[3][2]) -
183 m[1][2] * (
m[2][0] *
m[3][3] -
m[2][3] *
m[3][0]) +
184 m[1][3] * (
m[2][0] *
m[3][2] -
m[2][2] *
m[3][0])
187 m[1][0] * (
m[2][1] *
m[3][3] -
m[2][3] *
m[3][1]) -
188 m[1][1] * (
m[2][0] *
m[3][3] -
m[2][3] *
m[3][0]) +
189 m[1][3] * (
m[2][0] *
m[3][1] -
m[2][1] *
m[3][0])
192 m[1][0] * (
m[2][1] *
m[3][2] -
m[2][2] *
m[3][1]) -
193 m[1][1] * (
m[2][0] *
m[3][2] -
m[2][2] *
m[3][0]) +
194 m[1][2] * (
m[2][0] *
m[3][1] -
m[2][1] *
m[3][0])
float determinant() const
Computes the determinant of the matrix.
Matrix4x4 operator*(const Matrix4x4 &other) const
Multiplies this matrix by another matrix.
Matrix4x4(const Matrix4x4 &other)
Matrix4x4(float a11, float a12, float a13, float a14, float a21, float a22, float a23, float a24, float a31, float a32, float a33, float a34, float a41, float a42, float a43, float a44)
Parameterized constructor.
float m[4][4]
The elements of the matrix.
Matrix4x4 operator-(const Matrix4x4 &other) const
Subtracts another matrix from this matrix.
Matrix4x4 operator+(const Matrix4x4 &other) const
Adds another matrix to this matrix.