[FEAT] cylinder is now ok

This commit is contained in:
2024-03-19 23:06:30 +01:00
parent 38107165a7
commit fd5753efeb
3 changed files with 68 additions and 0 deletions

View File

@@ -313,3 +313,52 @@ SCENARIO("Intersecting the caps of a closed cylinder", "[features/cylinders.feat
}
}
}
/* ------------------------------------------------------------------------- */
SCENARIO("The normal vector on the cylinder's end caps", "[features/cylinders.feature]")
{
// | point | normal |
// | point(0, 1, 0) | vector(0, -1, 0) |
// | point(0.5, 1, 0) | vector(0, -1, 0) |
// | point(0, 1, 0.5) | vector(0, -1, 0) |
// | point(0, 2, 0) | vector(0, 1, 0) |
// | point(0.5, 2, 0) | vector(0, 1, 0) |
// | point(0, 2, 0.5) | vector(0, 1, 0) |
CylinderTestNormal the_test[] = {
{ Tuple::Point(0, 1, 0), Tuple::Vector(0, -1, 0)},
{Tuple::Point(0.5, 1, 0), Tuple::Vector(0, -1, 0)},
{ Tuple::Point(0, 1, 0.5), Tuple::Vector(0, -1, 0)},
{ Tuple::Point(0, 2, 0), Tuple::Vector(0, 1, 0)},
{Tuple::Point(0.5, 2, 0), Tuple::Vector(0, 1, 0)},
{ Tuple::Point(0, 2, 0.5), Tuple::Vector(0, 1, 0)}
};
GIVEN("cyl <- cylinder()")
{
Cylinder cyl;
AND_GIVEN("cyl.minimum <- 1")
{
cyl.set_minimum(1);
AND_GIVEN("cyl.maximum <- 2")
{
cyl.set_maximum(2);
AND_GIVEN("cyl.closed <- true")
{
cyl.set_closed(true);
WHEN("n <- local_normal_at(cyl,<point>)")
{
for (int i = 0; i < 6; i++)
{
Tuple p = the_test[i].point;
Tuple normal = cyl.local_normal_at(p);
THEN("n = <normal>")
{
REQUIRE(normal == the_test[i].normal);
}
}
}
}
}
}
}
}