[WIP] ADD normal_at method
This commit is contained in:
@@ -37,10 +37,13 @@ SCENARIO("The normal on a sphere at point a on the x axis", "[features/spheres.f
|
||||
{
|
||||
GIVEN("s <- sphere()")
|
||||
{
|
||||
Sphere s;
|
||||
WHEN("n <- normal_at(s, point(1,0,0))")
|
||||
{
|
||||
Tuple n = s.normal_at(Tuple::Point(1, 0, 0));
|
||||
THEN("n = vector(1,0,0)")
|
||||
{
|
||||
REQUIRE(n == Tuple::Vector(1, 0, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -52,10 +55,13 @@ SCENARIO("The normal on a sphere at point a on the y axis", "[features/spheres.f
|
||||
{
|
||||
GIVEN("s <- sphere()")
|
||||
{
|
||||
Sphere s;
|
||||
WHEN("n <- normal_at(s, point(0,1,0))")
|
||||
{
|
||||
Tuple n = s.normal_at(Tuple::Point(0, 1, 0));
|
||||
THEN("n = vector(0,1,0)")
|
||||
{
|
||||
REQUIRE(n == Tuple::Vector(0, 1, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -67,10 +73,13 @@ SCENARIO("The normal on a sphere at point a on the z axis", "[features/spheres.f
|
||||
{
|
||||
GIVEN("s <- sphere()")
|
||||
{
|
||||
Sphere s;
|
||||
WHEN("n <- normal_at(s, point(0,0,1))")
|
||||
{
|
||||
Tuple n = s.normal_at(Tuple::Point(0, 0, 1));
|
||||
THEN("n = vector(0,0,1)")
|
||||
{
|
||||
REQUIRE(n == Tuple::Vector(0, 0, 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -82,10 +91,13 @@ SCENARIO("The normal on a sphere at a nonaxial point", "[features/spheres.featur
|
||||
{
|
||||
GIVEN("s <- sphere()")
|
||||
{
|
||||
Sphere s;
|
||||
WHEN("n <- normal_at(s, point(sqrt(3)/3,sqrt(3)/3,sqrt(3)/3))")
|
||||
{
|
||||
THEN("n = vector(sqrt(3)/3,sqrt(3)/3,sqrt(3)/3)")
|
||||
Tuple n = s.normal_at(Tuple::Point(sqrt(3) / 3, sqrt(3) / 3, sqrt(3) / 3));
|
||||
THEN("n = vector(sqrt(3)/3,sqrt(3)/3,sqrt(3)/3))")
|
||||
{
|
||||
REQUIRE(n == Tuple::Vector(sqrt(3) / 3, sqrt(3) / 3, sqrt(3) / 3));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -97,10 +109,13 @@ SCENARIO("The normal is a normalized vector", "[features/spheres.feature]")
|
||||
{
|
||||
GIVEN("s <- sphere()")
|
||||
{
|
||||
Sphere s;
|
||||
WHEN("n <- normal_at(s, point(sqrt(3)/3,sqrt(3)/3,sqrt(3)/3))")
|
||||
{
|
||||
Tuple n = s.normal_at(Tuple::Point(sqrt(3) / 3, sqrt(3) / 3, sqrt(3) / 3));
|
||||
THEN("n = normalize(n)")
|
||||
{
|
||||
REQUIRE(n == n.normalize());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user