[FEAT] Add some chaines test
This commit is contained in:
@@ -201,3 +201,36 @@ TEST_CASE("[04][Trans] A shearing transformation moves z in proportion to y", "[
|
||||
|
||||
REQUIRE(transform * p == Tuple::Point(2, 3, 7));
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
TEST_CASE("[04][Trans] Individual transformations are applied in sequence", "[Matrix]")
|
||||
{
|
||||
Tuple p = Tuple::Point(1, 0, 1);
|
||||
Matrix a = Matrix::rotation_x(std::numbers::pi / 2);
|
||||
Matrix b = Matrix::scaling(5, 5, 5);
|
||||
Matrix c = Matrix::translation(10, 5, 7);
|
||||
|
||||
// Appply rotation first.
|
||||
Tuple p2 = a * p;
|
||||
REQUIRE(p2 == Tuple::Point(1, -1, 0));
|
||||
// Then Apply scaling
|
||||
Tuple p3 = b * p2;
|
||||
REQUIRE(p3 == Tuple::Point(5, -5, 0));
|
||||
// Then Apply translation
|
||||
Tuple p4 = c * p3;
|
||||
REQUIRE(p4 == Tuple::Point(15, 0, 7));
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
TEST_CASE("[04][Trans] Chained transformation must be applied in rever order", "[Matrix]")
|
||||
{
|
||||
Tuple p = Tuple::Point(1, 0, 1);
|
||||
Matrix a = Matrix::rotation_x(std::numbers::pi / 2);
|
||||
Matrix b = Matrix::scaling(5, 5, 5);
|
||||
Matrix c = Matrix::translation(10, 5, 7);
|
||||
Matrix t = c * b * a;
|
||||
|
||||
REQUIRE(t * p == Tuple::Point(15, 0, 7));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user