[FEAT] RAY: Add transform method
This commit is contained in:
@@ -227,3 +227,27 @@ TEST_CASE("[05][Rays] The hit is always the lowest nonnegative intersection", "[
|
||||
|
||||
REQUIRE(i == i4);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
TEST_CASE("[05][Rays] Translating a ray", "[Rays]")
|
||||
{
|
||||
Ray r(Tuple::Point(1, 2, 3), Tuple::Vector(0, 1, 0));
|
||||
Matrix m = Matrix::translation(3, 4, 5);
|
||||
Ray r2 = r.transform(m);
|
||||
|
||||
REQUIRE(r2.origin() == Tuple::Point(4, 6, 8));
|
||||
REQUIRE(r2.direction() == Tuple::Vector(0, 1, 0));
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
TEST_CASE("[05][Rays] Scaling a ray", "[Rays]")
|
||||
{
|
||||
Ray r(Tuple::Point(1, 2, 3), Tuple::Vector(0, 1, 0));
|
||||
Matrix m = Matrix::scaling(2, 3, 4);
|
||||
Ray r2 = r.transform(m);
|
||||
|
||||
REQUIRE(r2.origin() == Tuple::Point(2, 6, 12));
|
||||
REQUIRE(r2.direction() == Tuple::Vector(0, 3, 0));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user