7static constexpr bool approxEq(
const mat4& x,
const mat4&y)
25 SECTION(
"default constructor") {
65 SECTION(
"diagonal constructor") {
105 SECTION(
"construct from columns") {
124 mat4 m4(
vec4(2, 3, 4, 5),
vec4(3, 4, 5, 6),
vec4(4, 5, 6, 7),
vec4(5, 6, 7, 8));
130 imat4 i4(
ivec4(2, 3, 4, 5),
ivec4(3, 4, 5, 6),
ivec4(4, 5, 6, 7),
ivec4(5, 6, 7, 8));
150 m2[1] =
vec2(8, 9); m2[0][1] = 7;
155 i2[0] =
ivec2(8, 9); i2[1][1] = 7;
160 m3[1] =
vec3(7, 8, 9); m3[0][1] = 6;
172 m4[3] =
vec4(6, 7, 8, 9);
m4[1][1] = 1;
217 mat4 m4(
vec4(1, 2, 3, 4),
vec4(3, 4, 5, 6),
vec4(5, 6, 7, 8),
vec4(7, 8, 9, 0));
218 mat4 n4(
vec4(1, 2, 0, 4),
vec4(3, 4, 5, 6),
vec4(5, 6, 7, 8),
vec4(7, 8, 9, 0));
219 mat4 o4(
vec4(1, 2, 3, 4),
vec4(0, 4, 5, 6),
vec4(5, 6, 7, 8),
vec4(7, 8, 9, 0));
220 mat4 p4(
vec4(1, 2, 3, 4),
vec4(3, 4, 5, 6),
vec4(5, 0, 7, 8),
vec4(7, 8, 9, 0));
221 mat4 q4(
vec4(1, 2, 3, 4),
vec4(3, 4, 5, 6),
vec4(5, 6, 7, 8),
vec4(7, 8, 9, 1));
228 imat4 i4(
ivec4(1, 2, 3, 4),
ivec4(3, 4, 5, 6),
ivec4(5, 6, 7, 8),
ivec4(7, 8, 9, 0));
229 imat4 j4(
ivec4(1, 0, 3, 4),
ivec4(3, 4, 5, 6),
ivec4(5, 6, 7, 8),
ivec4(7, 8, 9, 0));
230 imat4 k4(
ivec4(1, 2, 3, 4),
ivec4(3, 4, 0, 6),
ivec4(5, 6, 7, 8),
ivec4(7, 8, 9, 0));
231 imat4 l4(
ivec4(1, 2, 3, 4),
ivec4(3, 4, 5, 6),
ivec4(5, 6, 7, 0),
ivec4(7, 8, 9, 0));
232 imat4 h4(
ivec4(1, 2, 3, 4),
ivec4(3, 4, 5, 6),
ivec4(5, 6, 7, 8),
ivec4(0, 8, 9, 0));
261 m[1][0] = 9;
CHECK(n != m);
262 n = m;
CHECK(n == m);
267 m[0][1] = 9;
CHECK(n != m);
268 n = m;
CHECK(n == m);
273 m[2][1] = 8;
CHECK(n != m);
274 n = m;
CHECK(n == m);
279 m[1][2] = 8;
CHECK(n != m);
280 n = m;
CHECK(n == m);
285 m[3][1] = 2;
CHECK(n != m);
286 n = m;
CHECK(n == m);
291 m[0][1] = 1;
CHECK(n != m);
292 n = m;
CHECK(n == m);
298 mat4 m4(
vec4(1, 2, 3, 4),
vec4(4, 5, 6, 7),
vec4(7, 8, 9, 1),
vec4(1, 0, 0, 0));
305 imat4 i4(
ivec4(1, 2, 3, 4),
ivec4(4, 5, 6, 7),
ivec4(7, 8, 9, 1),
ivec4(1, 0, 0, 0));
344 mat4 m4(
vec4(1, 2, 3, 4),
vec4(4, 5, 6, 7),
vec4(7, 8, 9, 1),
vec4(1, 0, 0, 0));
345 mat4 n4(
vec4(2, 4, 6, 8),
vec4(1, 3, 5, 7),
vec4(7, 8, 9, 2),
vec4(0, 0, 0, 1));
348 CHECK(
o4 ==
mat4(
vec4( 3, 6, 9, 12),
vec4(5, 8, 11, 14),
vec4(14, 16, 18, 3),
vec4(1, 0, 0, 1)));
349 CHECK(
p4 ==
mat4(
vec4(-1, -2, -3, -4),
vec4(3, 2, 1, 0),
vec4( 0, 0, 0, -1),
vec4(1, 0, 0, -1)));
354 CHECK(-
m4 ==
mat4(
vec4(-1, -2, -3, -4),
vec4(-4, -5, -6, -7),
vec4(-7, -8, -9, -1),
vec4(-1, 0, 0, 0)));
356 imat4 i4(
ivec4(0, 1, 2, 3),
ivec4(4, 3, 2, 1),
ivec4(1, 1, 1, 1),
ivec4(5, 5, 4, 4));
357 imat4 j4(
ivec4(2, 3, 4, 5),
ivec4(1, 1, 2, 2),
ivec4(0, 0, 1, 2),
ivec4(1, 2, 2, 0));
360 CHECK(
k4 ==
imat4(
ivec4( 2, 4, 6, 8),
ivec4(5, 4, 4, 3),
ivec4(1, 1, 2, 3),
ivec4(6, 7, 6, 4)));
361 CHECK(
l4 ==
imat4(
ivec4(-2, -2, -2, -2),
ivec4(3, 2, 0, -1),
ivec4(1, 1, 0, -1),
ivec4(4, 3, 2, 4)));
366 CHECK(-
i4 ==
imat4(
ivec4(0, -1, -2, -3),
ivec4(-4, -3, -2, -1),
ivec4(-1, -1, -1, -1),
ivec4(-5, -5, -4, -4)));
397 mat4 m4(
vec4(1, 2, 3, 4),
vec4(4, 5, 6, 7),
vec4( 7, 8, 9, 10),
vec4(0, 0, -1, -2));
398 mat4 n4(
vec4(2, 4, 6, 8),
vec4(8, 10, 12, 14),
vec4(14, 16, 18, 20),
vec4(0, 0, -2, -4));
404 imat4 i4(
ivec4(0, 1, 2, 3),
ivec4(1, 0, 0, 2),
ivec4(3, 2, 1, 0),
ivec4(0, 0, -1, -2));
405 imat4 j4(
ivec4(0, 3, 6, 9),
ivec4(3, 0, 0, 6),
ivec4(9, 6, 3, 0),
ivec4(0, 0, -3, -6));
433 mat4 m4(
vec4(1, 2, 3, 4),
vec4(4, 5, 6, 7),
vec4(7, 8, 9, 1),
vec4(0, 1, 0, -1));
440 imat4 i4(
ivec4(-1, 2, 0, -3),
ivec4(0, 1, 2, -1),
ivec4(0, 1, 1, 0),
ivec4(-1, 1, 0, -1));
467 mat4 m4(
vec4(1, -1, 1, 0),
vec4(2, 0, -1, 1),
vec4(0, 1, 1, -1),
vec4(2, 0, 1, -1));
468 mat4 n4(
vec4(1, 1, -1, 1),
vec4(0, -2, 1, 0),
vec4(1, 0, 1, -1),
vec4(0, 1, 2, -2));
469 CHECK((
m4 *
n4) ==
mat4(
vec4(5, -2, 0, 1),
vec4(-4, 1, 3, -3),
vec4(-1, 0, 1, 0),
vec4(-2, 2, -1, 1)));
470 CHECK((
n4 *
m4) ==
mat4(
vec4(2, 3, -1, 0),
vec4( 1, 3, -1, 1),
vec4( 1, -3, 0, 1),
vec4( 3, 1, -3, 3)));
472 imat4 i4(
ivec4(1, -1, 1, 2),
ivec4(2, -1, -1, 1),
ivec4(2, 1, 1, -1),
ivec4( 2, -1, 1, -1));
473 imat4 j4(
ivec4(1, 1, -1, 1),
ivec4(2, -2, 1, -1),
ivec4(1, -2, 1, -1),
ivec4(-1, 1, 2, -2));
474 CHECK((
i4 *
j4) ==
imat4(
ivec4(3, -4, 0, 3),
ivec4(-2, 2, 4, 2),
ivec4(-3, 3, 3, 0),
ivec4(1, 4, -2, -1)));
492 mat4 m4(
vec4(1, -1, 1, 0),
vec4(2, 0, -1, 1),
vec4(0, 1, 1, -1),
vec4(2, 0, 1, -1));
493 CHECK(
transpose(
m4) ==
mat4(
vec4(1, 2, 0, 2),
vec4(-1, 0, 1, 0),
vec4(1, -1, 1, 1),
vec4(0, 1, -1, -1)));
495 imat4 i4(
ivec4(1, -1, 1, 2),
ivec4(2, -1, -1, 1),
ivec4(2, 1, 1, -1),
ivec4(2, -1, 1, -1));
496 CHECK(
transpose(
i4) ==
imat4(
ivec4(1, 2, 2, 2),
ivec4(-1, -1, 1, -1),
ivec4(1, -1, 1, 1),
ivec4(2, 1, -1, -1)));
522 mat4 m4(
vec4(0, 1, 1, 0),
vec4(-1, 0, 1, 0),
vec4(1, 1, 0, -1),
vec4(0, 1, 0, 0));
525 CHECK(approxEq(
i4,
mat4(
vec4(1, -1, 0, -1),
vec4(0, 0, 0, 1),
vec4(1, 0, 0, -1),
vec4(1, -1, -1, 0))));
538 mat4 m4(
vec4(1, -1, 1, 2),
vec4(2, 0, -1, 1),
vec4(0, 1, 1, 0),
vec4(0, 1, 1, 3));
541 imat4 i4(
ivec4(1, 2, 1, -3),
ivec4(-2, 3, -1, 0),
ivec4(2, 1, 4, -2),
ivec4(0, 2, 2, 2));
557void test_constr(
mat4& A)
561void test_constr(
const vec4& x,
mat4& A)
567 A =
mat4(x, y, z, w);
569void test_constr(
const mat4& A,
mat3& B)
574void test_change0(
const vec4& x,
mat4& A)
578void test_change2(
const vec4& x,
mat4& A)
582void test_extr0(
const mat4& A,
vec4& x)
586void test_extr2(
const mat4& A,
vec4& x)
591bool test_equal(
const mat4& A,
const mat4& B)
595bool test_not_equal(
const mat4& A,
const mat4& B)
604void test_add(
const mat4& A,
mat4& B)
612void test_negate(
const mat4& A,
mat4& B)
617void test_mul(
float x,
const mat4& A,
mat4& B)
630void test_transpose(
const mat4& A,
mat4& B)
635void test_determinant(
const mat4& A,
float& x)
640void test_inverse(
const mat4& A,
mat4& B)
645void test_norm(
const mat4& A,
float& x)
mat23 o23(vec2(2, 3), vec2(4, 0), vec2(6, 7))
matMxN< 2, 3, float > mat23
matMxN< 4, 4, int > imat4
mat23 p23(vec2(2, 3), vec2(4, 5), vec2(0, 7))
mat3 n3(vec3(1, 0, 3), vec3(4, 5, 6), vec3(7, 8, 9))
imat4 k4(ivec4(1, 2, 3, 4), ivec4(3, 4, 0, 6), ivec4(5, 6, 7, 8), ivec4(7, 8, 9, 0))
matMxN< 3, 2, float > mat32
imat4 i4(ivec4(1, 2, 3, 4), ivec4(3, 4, 5, 6), ivec4(5, 6, 7, 8), ivec4(7, 8, 9, 0))
matMxN< 2, 2, int > imat2
mat32 m32(vec3(2, 3, 4), vec3(5, 6, 7))
mat4 o4(vec4(1, 2, 3, 4), vec4(0, 4, 5, 6), vec4(5, 6, 7, 8), vec4(7, 8, 9, 0))
mat3 o3(vec3(1, 2, 3), vec3(4, 5, 0), vec3(7, 8, 9))
imat3 l3(ivec3(0, 2, 3), ivec3(4, 5, 6), ivec3(7, 8, 9))
imat4 j4(ivec4(1, 0, 3, 4), ivec4(3, 4, 5, 6), ivec4(5, 6, 7, 8), ivec4(7, 8, 9, 0))
mat4 m4(vec4(1, 2, 3, 4), vec4(3, 4, 5, 6), vec4(5, 6, 7, 8), vec4(7, 8, 9, 0))
TEST_CASE("gl_mat: constructors")
mat4 n4(vec4(1, 2, 0, 4), vec4(3, 4, 5, 6), vec4(5, 6, 7, 8), vec4(7, 8, 9, 0))
imat3 k3(ivec3(1, 2, 3), ivec3(4, 5, 0), ivec3(7, 8, 9))
imat3 j3(ivec3(1, 2, 3), ivec3(4, 5, 6), ivec3(7, 0, 9))
imat4 h4(ivec4(1, 2, 3, 4), ivec4(3, 4, 5, 6), ivec4(5, 6, 7, 8), ivec4(0, 8, 9, 0))
mat23 n23(vec2(0, 3), vec2(4, 5), vec2(6, 7))
mat4 p4(vec4(1, 2, 3, 4), vec4(3, 4, 5, 6), vec4(5, 0, 7, 8), vec4(7, 8, 9, 0))
mat32 o32(vec3(2, 3, 4), vec3(0, 6, 7))
mat3 p3(vec3(1, 2, 3), vec3(4, 5, 6), vec3(7, 0, 9))
mat4 q4(vec4(1, 2, 3, 4), vec4(3, 4, 5, 6), vec4(5, 6, 7, 8), vec4(7, 8, 9, 1))
imat3 i3(ivec3(1, 2, 3), ivec3(4, 5, 6), ivec3(7, 8, 9))
mat32 n32(vec3(2, 3, 0), vec3(5, 6, 7))
matMxN< 3, 3, int > imat3
imat4 l4(ivec4(1, 2, 3, 4), ivec4(3, 4, 5, 6), ivec4(5, 6, 7, 0), ivec4(7, 8, 9, 0))
mat23 m23(vec2(2, 3), vec2(4, 5), vec2(6, 7))
constexpr T norm2_2(const matMxN< M, N, T > &A)
matMxN< 3, 3, float > mat3
matMxN< 4, 4, float > mat4
matMxN< 2, 2, float > mat2
constexpr matMxN< N, M, T > transpose(const matMxN< M, N, T > &A)
constexpr matMxN< 2, 2, T > inverse(const matMxN< 2, 2, T > &A)
constexpr T determinant(const matMxN< 2, 2, T > &A)
std::array< const EDStorage, 4 > A