Example #1
0
 def then_plane_has_correct_distances(self):
     ray_length = vector_norm(self.unit_direction)
     self.assertEqual(1.0, ray_length)
     ray = self.unit_ray
     for scale in [-2.0, -1.0, 0.0, 0.4, 1.0]:
         point = ray.scaled_endpoint(scale)
         distance_from_plane = self.plane.distance_to_point(point)
         self.assertAlmostEqual(scale, distance_from_plane)
Example #2
0
 def setUp(self):
     self.clean_state()
     self.vector = (2.0, 3.0, 4.0)
     vector_length = vector_norm(self.vector)
     self.unit_vector = tuple(component / vector_length for component in self.vector)
     self.position = Position.from_xyz((10.0, 20.0, 30.0))
     self.direction = Direction.from_xyz(self.vector)
     self.unit_direction = Direction.from_xyz(self.unit_vector)
     self.ray = Ray(self.position, self.direction)
     self.unit_ray = Ray(self.position, self.unit_direction)
     self.other_position = Position.from_xyz((-9.0, -88.0, 12.34))
     self.other_direction = Direction.from_xyz((19.0, 8.0, -0.03))
     self.other_ray = Ray(self.other_position, self.other_direction)
     offset = self.position.dot(self.unit_direction)
     plane_projector = (-offset,) + self.unit_vector
     self.plane = Plane(plane_projector)
     self.orthogonal_directions = [
         Direction.from_xyz((0.2, 0.2, -0.25)),
         Direction.from_xyz((-7.0, 2.0, 2.0))
     ]
     self.orthogonal_rays = [Ray(self.position, direction)
                             for direction in self.orthogonal_directions]
Example #3
0
 def then_filter_wavefront_has_correct_properties(self):
     distance_to_aperture = vector_norm(self.aperture_origin.xyz)
     tangent = self.aperture.radius / distance_to_aperture
     expected_volume = self.volume_of_spherical_cone(tangent)
     actual_volume = self.filtered_wavefront.volume
     self.assertAlmostEqual(expected_volume, actual_volume, 3)
Example #4
0
 def test_vector_norm(self):
     self.assertAlmostEqual(5.0, vector_norm((3.0, 4.0)))
Example #5
0
 def test_direction_normalized(self):
     self.when_direction_created_from_xyz()
     self.direction = self.direction.normalized()
     self.assertAlmostEqual(1.0, vector_norm(self.direction))