def test_solid_cone_closest_pt_to_on_axis(self): from lepton.domain import Cone cone = Cone((0, 3, 0), (0, 0, 0), 3) for point, closest, normal in [ ((0, 4, 0), (0, 3, 0), (0, 1, 0)), ((0, 3, 0), (0, 3, 0), (0, 0, 0)), ((0, 2, 0), (0, 2, 0), (0, 0, 0)), ((0, -2, 0), (0, 0, 0), (0, -1, 0)), ((0, 0, 0), (0, 0, 0), (0, 0, 0)), ]: p, N = cone.closest_point_to(point) self.assertVector(p, closest) self.assertVector(N, normal)
def test_cone_closest_pt_to(self): from lepton.domain import Cone from lepton.particle_struct import Vec3 cone = Cone((0, 1, -2), (3, -2, -2), math.sqrt(18), 1) for point, closest, normal in [ ((1, 2, -2), (1, 1, -2), (0, 1, 0)), ((-1, -1, -2), (0, -1, -2), (-1, 0, 0)), ((-1, -2, -2), (0, -2, -2), (-1, 0, 0)), ((-1, 3, -1), (0, 1, -2), Vec3(-1, 1, 0).normalize()), ((-4, 5, -2), (0, 1, -2), Vec3(-1, 1, 0).normalize()), ((6, 0, -2), (5.5, 0.5, -2), Vec3(1, -1, 0).normalize()), ((1.566666, -0.566666, -2.1), (1.5, -0.5, -2.5), Vec3(-1, 1, -6).normalize()), ((2, 0, -3.5), (2, 0, -3.5), (0, 0, 0)), ((10, -9, -2), (0, 1, -2), Vec3(1, -1, 0).normalize()), ((1, 0, -2), (0, 1, -2), Vec3(1, -1, 0).normalize()), ((0, 1, -2), (0, 1, -2), (0, 0, 0)), ]: p, N = cone.closest_point_to(point) self.assertVector(p, closest) self.assertVector(N, normal)