[WIP] ADD normal_at method

This commit is contained in:
NADAL Jean-Baptiste
2024-02-15 15:47:37 +01:00
parent 4d57e60ecb
commit 804822ec86
6 changed files with 33 additions and 4 deletions

View File

@@ -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());
}
}
}

View File

@@ -21,4 +21,6 @@ add_executable(raytracing_test
include_directories("${CMAKE_SOURCE_DIR}/tests")
target_link_libraries(raytracing_test PRIVATE raytracing)
target_link_libraries(raytracing_test PRIVATE raytracing gcov)
add_test(NAME raytracing_test COMMAND tests/raytracing_test)