8TEST_CASE(
"Mat Size Tests",
"[math_matrix_test]" )
102 input1.
set(-1, 0, 1, 2);
103 input2.
set(1, 2, 3, 4, 5, 6, 7, 8, 9);
105 input3.
set({ -8, -7, -6, -5, -4, -3, -2, -1, 1, 2, 3, 4, 5, 6, 7, 8 });
106 for (
U8 i = 0; i < 16; ++i) {
107 input4.
mat[i] = 22.345f * (i + 1);
118 U8 row = 0u, column = 0u;
119 U8 elementsPerLine = 2;
120 for (row = 0; row < elementsPerLine; ++row) {
121 for (column = 0; column < elementsPerLine; ++column) {
126 for (row = 0; row < elementsPerLine; ++row) {
127 for (column = 0; column < elementsPerLine; ++column) {
132 for (row = 0; row < elementsPerLine; ++row) {
133 for (column = 0; column < elementsPerLine; ++column) {
138 for (row = 0; row < elementsPerLine; ++row) {
139 for (column = 0; column < elementsPerLine; ++column) {
152 const mat4<F32> input3({1.0f, 2.0f, 3.0f, 4.0f,
153 5.0f, 6.0f, 7.0f, 8.0f,
154 9.0f, 10.0f, 11.0f, 12.0f,
155 13.0f, 14.0f, 15.0f, 16.0f});
164 const vec4<F32> result3A(1.0f, 5.0f, 9.0f, 13.0f);
165 const vec4<F32> result3B(2.0f, 6.0f, 10.0f, 14.0f);
166 const vec4<F32> result3C(3.0f, 7.0f, 11.0f, 15.0f);
167 const vec4<F32> result3D(4.0f, 8.0f, 12.0f, 16.0f);
190 const mat4<F32> input3({1.0f, 2.0f, 3.0f, 4.0f,
191 5.0f, 6.0f, 7.0f, 8.0f,
192 9.0f, 10.0f, 11.0f, 12.0f,
193 13.0f, 14.0f, 15.0f, 16.0f});
203 const vec4<F32> result3A(1.0f, 2.0f, 3.0f, 4.0f);
204 const vec4<F32> result3B(5.0f, 6.0f, 7.0f, 8.0f);
205 const vec4<F32> result3C(9.0f, 10.0f, 11.0f, 12.0f);
206 const vec4<F32> result3D(13.0f, 14.0f, 15.0f, 16.0f);
221TEST_CASE(
"Mat equalityOperator Tests",
"[math_matrix_test]" )
229 input1[0].
set(-1, 0, 1, 2);
230 input1[1].
set(-1, 0, 1, 2);
232 CHECK_FALSE(input1[0] != input1[1]);
233 input1[1].
mat[2] = 2;
235 CHECK_FALSE(input1[0] == input1[1]);
237 input2[0].
set(1, 2, 3, 4, 5, 6, 7, 8, 9);
238 input2[1].
set(1, 2, 3, 4, 5, 6, 7, 8, 9);
241 CHECK_FALSE(input2[0] != input2[1]);
242 input2[1].
m[2][0] = 22;
244 CHECK_FALSE(input2[0] == input2[1]);
246 input3[0].
set({ -8, -7, -6, -5, -4, -3, -2, -1, 1, 2, 3, 4, 5, 6, 7, 8 });
247 input3[1].
set({ -8, -7, -6, -5, -4, -3, -2, -1, 1, 2, 3, 4, 5, 6, 7, 8 });
249 CHECK_FALSE(input3[0] != input3[1]);
250 input3[1].
m[1][3] = 22;
252 CHECK_FALSE(input3[0] == input3[1]);
254 for (
U8 i = 0; i < 2; ++i) {
255 for (
U8 j = 0; j < 16; ++j) {
256 input4[i].
mat[j] = 22.345f * j * (j % 2 == 0 ? -1.0f : 1.0f);
260 CHECK_FALSE(input4[0] != input4[1]);
262 for (
U8 i = 0; i < 2; ++i) {
263 for (
U8 j = 0; j < 16; ++j) {
264 input4[i].
mat[j] = 22.345f * (j + i + 1);
269 CHECK_FALSE(input4[0] == input4[1]);
282 const mat3<F32> result2(1.0f, 0.0f, 0.0f,
291 const mat4<F32> result3({1.0f, 0.0f, 0.0f, 0.0f,
292 0.0f, 1.0f, 0.0f, 0.0f,
293 0.0f, 0.0f, 1.0f, 0.0f,
294 0.0f, 0.0f, 0.0f, 1.0f});
302 mat2<F32> input1(1.0f, 2.0f, 3.0f, 4.0f);
303 const mat2<F32> result1(1.0f, 3.0f, 2.0f, 4.0f);
304 const mat2<F32> result2(1.0f, 2.0f, 3.0f, 4.0f);
313 mat3<I32> input2(1, 2, 3, 4, 5, 6, 7, 8, 9);
314 const mat3<I32> result3(1, 4, 7, 2, 5, 8, 3, 6, 9);
315 const mat3<I32> result4(1, 2, 3, 4, 5, 6, 7, 8, 9);
324 mat4<F32> input3({1.0f, 2.0f, 3.0f, 4.0f,
325 5.0f, 6.0f, 7.0f, 8.0f,
326 9.0f, 10.0f, 11.0f, 12.0f,
327 13.0f, 14.0f, 15.0f, 16.0f});
328 const mat4<F32> result5({1.0f, 5.0f, 9.0f, 13.0f,
329 2.0f, 6.0f, 10.0f, 14.0f,
330 3.0f, 7.0f, 11.0f, 15.0f,
331 4.0f, 8.0f, 12.0f, 16.0f});
332 const mat4<F32> result6({1.0f, 2.0f, 3.0f, 4.0f,
333 5.0f, 6.0f, 7.0f, 8.0f,
334 9.0f, 10.0f, 11.0f, 12.0f,
335 13.0f, 14.0f, 15.0f, 16.0f});
344TEST_CASE(
"Mat-Scalar Multiply Tests",
"[math_matrix_test]" )
352 CHECK_FALSE(input1 == result1);
356 const mat3<F32> input2(-5.0f, -4.0f, -3.0f,
359 const mat3<F32> result2( 2.5f, 2.0f, 1.5f,
361 -1.0f, -1.5f, -2.0f);
363 CHECK_FALSE(input2 == result2);
376 CHECK_FALSE(input3 == result3);
379 const mat4<F32> input4({1.0f, 2.0f, 3.0f, 4.0f,
380 5.0f, 6.0f, 7.0f, 8.0f,
381 9.0f, 8.0f, 7.0f, 6.0f,
382 5.0f, 4.0f, 3.0f, 2.0f});
384 const mat4<F32> result4A({ 3.0f, 6.0f, 9.0f, 12.0f,
385 15.0f, 18.0f, 21.0f, 24.0f,
386 27.0f, 24.0f, 21.0f, 18.0f,
387 15.0f, 12.0f, 9.0f, 6.0f});
389 const mat4<F32> result4B({ 0.5f, 1.0f, 1.5f, 2.0f,
390 2.5f, 3.0f, 3.5f, 4.0f,
391 4.5f, 4.0f, 3.5f, 3.0f,
392 2.5f, 2.0f, 1.5f, 1.0f });
394 CHECK_FALSE(input4 == result4A);
402TEST_CASE(
"Mat-Scalar Add-Subtract Tests",
"[math_matrix_test]" )
404 const mat4<F32> input({1.0f, 2.0f, 3.0f, 4.0f,
405 5.0f, 6.0f, 7.0f, 8.0f,
406 9.0f, 8.0f, 7.0f, 6.0f,
407 5.0f, 4.0f, 3.0f, 2.0f});
409 const mat4<F32> resultA({-2.0f, -1.0f, 0.0f, 1.0f,
410 2.0f, 3.0f, 4.0f, 5.0f,
411 6.0f, 5.0f, 4.0f, 3.0f,
412 2.0f, 1.0f, 0.0f, -1.0f});
414 const mat4<F32> resultB({ 4.0f, 5.0f, 6.0f, 7.0f,
415 8.0f, 9.0f, 10.0f, 11.0f,
416 12.0f, 11.0f, 10.0f, 9.0f,
417 8.0f, 7.0f, 6.0f, 5.0f });
424TEST_CASE(
"Mat-Scalar Division Tests",
"[math_matrix_test]" )
428 CHECK_FALSE((input1 / 2) == (input1 * 2));
431 const mat3<F32> input2(-5.0f, -4.0f, -3.0f,
434 CHECK_FALSE((input2 / 2) == (input2 * 2));
441 CHECK_FALSE((input3 / 2) == (input3 * 2));
445 const mat4<F32> input4({1.0f, 2.0f, 3.0f, 4.0f,
446 5.0f, 6.0f, 7.0f, 8.0f,
447 9.0f, 8.0f, 7.0f, 6.0f,
448 5.0f, 4.0f, 3.0f, 2.0f});
449 CHECK_FALSE((input4 / 2) == (input4 * 2));
453TEST_CASE(
"Mat-Plane Reflect Tests",
"[math_matrix_test]" )
462 reflectMat.
reflect(reflectPlane1);
466 reflectMat.
reflect(reflectPlane2);
471TEST_CASE(
"Mat-Mat Multiply Tests",
"[math_matrix_test]" )
496 const mat3<F32> input2A( 5.0f, 2.0f, 6.0f,
500 const mat3<F32> input2B(24.0f, 92.0f, 112.0f,
504 const mat3<F32> result2A( 388.0f, 472.0f, 804.0f,
505 1170.0f, 2138.0f, 5430.0f,
506 2912.0f, 5952.0f, 7456.0f);
508 const mat3<F32> result2B(9404.0f, 2716.0f, 4740.0f,
509 6105.0f, 10.0f, 3070.0f,
510 837.0f, 144.0f, 568.0f);
534 const mat4<I32> result3A({ 428, 528, 892, 614,
535 1195, 2173, 5485, 584,
536 2952, 6008, 7544, 1080,
537 283, -163, 325, 132 });
539 const mat4<I32> result3B({9396, 2736, 4768, 1552,
542 756, 548, 928, 230});
556 const mat4<F32> input4A({24.300f, 92.000f, 1.200f, 4.300f,
557 5.000f, 0.000f, 95.500f, 0.200f,
558 43.000f, 2.110f, 9.000f, 9.200f,
559 5.000f, 7.000f, 11.000f, 6.435f});
561 const mat4<F32> input4B({ 12.500f, 2.000f, 6.000f, 8.400f,
562 23.000f, 29.340f, 11.000f, 5.120f,
563 -64.500f, 22.000f, 3.200f, 8.000f,
564 -2.000f, 5.000f, 7.000f, 1.000f });
566 const mat4<F32> result4A({ 2333.750f, 2795.780f, 1191.740f, 689.060f,
567 -6097.650f, 2112.000f, 337.000f, 806.200f,
568 -12.870f, 391.907f, 374.410f, 453.203f,
569 -498.869f, 489.554f, 187.243f, 172.275f });
571 const mat4<F32> result4B({ 613.750f, 1221.460f, 352.400f, 163.401f,
572 1204.200f, 2175.050f, 2984.890f, 238.914f,
573 -1279.750f, -5871.248f, 2140.400f, -192.032f,
574 282.400f, -162.230f, 549.100f, 63.235f});
577 CHECK_TRUE(result4A.compare(input4A * input4B, 0.02f));
578 CHECK_FALSE(result4A.compare(input4B * input4A, 0.02f));
580 CHECK_FALSE(result4B.compare(input4A * input4B, 0.02f));
581 CHECK_TRUE(result4B.compare(input4B * input4A, 0.02f));
583 CHECK_TRUE(input4A.compare(input4A * inputIdentity4x4f, 0.02f));
588 const mat4<F32> input4A({ 24.300f, 92.000f, 1.200f, 4.300f,
589 5.000f, 0.000f, 95.500f, 0.200f,
590 43.000f, 2.110f, 9.000f, 9.200f,
591 5.000f, 7.000f, 11.000f, 6.435f });
593 const mat4<F32> resultA(&input4A.mat[0]);
594 const mat4<F32> resultB({input4A.mat[0], input4A.mat[1], input4A.mat[2], input4A.mat[3],
595 input4A.mat[4], input4A.mat[5], input4A.mat[6], input4A.mat[7],
596 input4A.mat[8], input4A.mat[9], input4A.mat[10], input4A.mat[11],
597 input4A.mat[12], input4A.mat[13], input4A.mat[14], input4A.mat[15]});
617 const mat3<F32> rezult3x3( 0.5f, -0.25f, 0.0f,
631 mat4<F32> input1({1.0f, 1.0f, 0.0f, 0.0f,
632 1.0f, 1.0f, 1.0f, 0.0f,
633 0.0f, 1.0f, 1.0f, 0.0f,
634 0.0f, 0.0f, 0.0f, 1.0f});
635 const mat4<F32> result1({ 0.0f, 1.0f, -1.0f, 0.0f,
636 1.0f, -1.0f, 1.0f, 0.0f,
637 -1.0f, 1.0f, 0.0f, 0.0f,
638 0.0f, 0.0f, 0.0f, 1.0f});
void set(U m0, U m1, U m2, U m3) noexcept
vec2< T > getRow(I32 index) const noexcept
vec2< T > getCol(I32 index) const noexcept
mat2 getTranspose() const noexcept
void transpose() noexcept
T & element(U8 row, U8 column) noexcept
mat3 getTranspose() const noexcept
const vec3< T > & getRow(I32 index) const noexcept
vec3< T > getCol(I32 index) const noexcept
T & element(U8 row, U8 column) noexcept
void set(U m0, U m1, U m2, U m3, U m4, U m5, U m6, U m7, U m8) noexcept
void transpose() noexcept
T & element(U8 row, U8 column) noexcept
const mat4 & reflect(U x, U y, U z, U w) noexcept
void set(std::initializer_list< T > matrix) noexcept
Handle console commands that start with a forward slash.
bool COMPARE(T X, U Y) noexcept
TEST_CASE("ByteBuffer RW Bool", "[byte_buffer]")
#define CHECK_NOT_EQUAL(LHS, RHS)
#define CHECK_EQUAL(LHS, RHS)