コード例 #1
0
ファイル: tests.py プロジェクト: jacrocitto/RayCaster
 def test_determine_diffuse_contribution(self):
     sphere = data.Sphere(data.Point(0, 0, 0), 1, data.Color(0.5, 0.7, 0.8), data.Finish(0.5, 0.5, 0.5, 0.05))
     light = data.Light(data.Point(0, 0, 100), data.Color(1.5, 1.2, 1.3))
     inter_point = data.Point(0, 0, 1)
     inter_list = [
         (
             data.Sphere(data.Point(0, 0, 102), 1, data.Color(0.5, 0.7, 0.8), data.Finish(0.5, 0.5, 0.5, 0.05)),
             data.Point(0, 0, 101),
         )
     ]
     normal = collisions.sphere_normal_at_point(sphere, inter_point)
     off_pt = cast.find_pt_off_sphere(inter_point, normal)
     dir_vect = vector_math.normalize_vector(vector_math.vector_from_to(off_pt, light.pt))
     ray = data.Ray(off_pt, dir_vect)
     sphere_list = []
     l_dir = vector_math.normalize_vector(vector_math.vector_from_to(off_pt, light.pt))
     l_dot_n = vector_math.dot_vector(normal, l_dir)
     result = cast.determine_diffuse_contribution(sphere, off_pt, light, normal, sphere_list, l_dir, l_dot_n)
     self.assertEqual(
         result[0], cast.get_diffuse_contribution(sphere, light, ray, inter_list, normal, dir_vect, off_pt)[0]
     )
     self.assertEqual(
         result[1], cast.get_diffuse_contribution(sphere, light, ray, inter_list, normal, dir_vect, off_pt)[1]
     )
     self.assertEqual(
         result[2], cast.get_diffuse_contribution(sphere, light, ray, inter_list, normal, dir_vect, off_pt)[2]
     )
コード例 #2
0
ファイル: tests.py プロジェクト: jacrocitto/RayCaster
 def test_get_diffuse_contribution(self):
     sphere = data.Sphere(data.Point(0, 0, 0), 1, data.Color(0.5, 0.7, 0.8), data.Finish(0.5, 0.5, 0.5, 0.05))
     light = data.Light(data.Point(0, 0, 100), data.Color(1.5, 1.2, 1.3))
     inter_point = data.Point(0, 0, 1)
     normal = collisions.sphere_normal_at_point(sphere, inter_point)
     inter_list = []
     off_pt = cast.find_pt_off_sphere(inter_point, normal)
     dir_vect = vector_math.normalize_vector(vector_math.vector_from_to(off_pt, light.pt))
     ray = data.Ray(off_pt, dir_vect)
     result = cast.get_diffuse_contribution(sphere, light, ray, inter_list, normal, dir_vect, off_pt)
     self.assertEqual(result[0], (vector_math.dot_vector(normal, dir_vect) * 1.5 * 0.5 * 0.5))
     self.assertEqual(result[1], (vector_math.dot_vector(normal, dir_vect) * 1.2 * 0.7 * 0.5))
     self.assertEqual(result[2], (vector_math.dot_vector(normal, dir_vect) * 1.3 * 0.8 * 0.5))