Finally! We have reflections!

This commit is contained in:
Godzil
2020-02-21 17:21:06 +00:00
parent 9fffb68026
commit 7337ae4837
9 changed files with 174 additions and 12 deletions

View File

@@ -9,6 +9,7 @@
#include <intersect.h>
#include <intersection.h>
#include <sphere.h>
#include <plane.h>
#include <transformation.h>
#include <gtest/gtest.h>
@@ -189,4 +190,15 @@ TEST(IntersectTest, The_hit_should_offset_the_point)
ASSERT_LT(comps.overHitPoint.z, -getEpsilon() / 2);
ASSERT_GT(comps.hitPoint.z, comps.overHitPoint.z);
}
TEST(IntersectTest, Precomputing_the_reflection_vector)
{
Plane s = Plane();
Ray r = Ray(Point(0, 1, -1), Vector(0, -sqrt(2) / 2, sqrt(2) / 2));
Intersection i = Intersection(sqrt(2), &s);
Computation comps = i.prepareComputation(r);
ASSERT_EQ(comps.reflectVector, Vector(0, sqrt(2) / 2, sqrt(2) / 2));
}