Example #1
0
 def reflect(self, ray):
     intercept = self.intersection_point(ray)
     if intercept == None:
         return None
     normal_to_surface = intercept.difference(self.sphere.center_position).normalized()
     normal_component_of_ray = vector_dot_product( ray.direction.xyz, normal_to_surface.xyz)
     reflection_action = normal_to_surface.scale(-2.0 * normal_component_of_ray)
     reflected_direction = ray.direction.add(reflection_action)
     return Ray(ray.position, reflected_direction)
Example #2
0
 def then_reflected_ray_is_opposite_of_aperture_normal(self):
     dotProduct = vector_dot_product(self.aperture_normal.xyz, self.reflected_ray.direction.xyz)
     self.assertAlmostEqual(-1.0, dotProduct)
Example #3
0
 def test_vector_dot_product(self):
     self.assertEqual(123, vector_dot_product((1, 2, 3), (100, 10, 1)))