[FEAT] Add identity matrix

This commit is contained in:
NADAL Jean-Baptiste
2024-02-02 14:50:07 +01:00
parent 221a1e01e3
commit 5866f77915
3 changed files with 46 additions and 0 deletions

View File

@@ -171,3 +171,26 @@ TEST_CASE("[Matrix] a matrix multiplied by a tuple", "[Matrix]")
REQUIRE((a * b) == Tuple(18, 24, 33, 1));
}
/* ------------------------------------------------------------------------- */
TEST_CASE("[Matrix] Multiplying a matrix by the identity matrix", "[Matrix]")
{
Matrix a = {
{0, 1, 2, 4},
{1, 2, 4, 8},
{2, 4, 8, 16},
{4, 8, 16, 32}
};
REQUIRE((a * Matrix::identity()) == a);
}
/* ------------------------------------------------------------------------- */
TEST_CASE("[Matrix] Multiplying the identity matrix by a tuple", "[Matrix]")
{
Tuple a(1, 2, 3, 4);
REQUIRE((Matrix::identity() * a) == a);
}