Пример #1
0
 def test_solid_cyl_closest_pt_to_on_axis(self):
     from lepton.domain import Cylinder
     cyl = Cylinder((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 = cyl.closest_point_to(point)
         self.assertVector(p, closest)
         self.assertVector(N, normal)
Пример #2
0
	def test_solid_cyl_closest_pt_to_on_axis(self):
		from lepton.domain import Cylinder
		cyl = Cylinder((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 = cyl.closest_point_to(point)
			self.assertVector(p, closest)
			self.assertVector(N, normal)
Пример #3
0
	def test_cyl_closest_pt_to(self):
		from lepton.domain import Cylinder
		from lepton.particle_struct import Vec3
		cyl = Cylinder((-2, 3, 0), (0, 3, 0), 3, 2)
		for point, closest, normal in [
			((-1, 7, 0), (-1, 6, 0), (0, 1, 0)),
			((-2, 3, -6), (-2, 3, -3), (0, 0, -1)),
			((0, 6, 3), Vec3(0, 3, 0) + Vec3(0, 1, 1).normalize() * 3, Vec3(0, 1, 1).normalize()),
			((-2.2, 5.5, 0), (-2, 5.5, 0), (-1, 0, 0)),
			((-5, 10, 0), (-2, 6, 0), (-1, 0, 0)),
			((-10, 3, 1), (-2, 3, 2), (-1, 0, 0)),
			((0.5, 0, 0), (0, 0, 0), (1, 0, 0)),
			((3, 5, 0), (0, 5, 0), (1, 0, 0)),
			((20, 3, -0.1), (0, 3, -2), (1, 0, 0)),
			# points inside cylinder and along axis
			((-0.5, 5.5, 0), (-0.5, 5.5, 0), (0, 0, 0)),
			((-1, 3, 0), (-1, 3, 0), (0, 0, 0)),
			((-30, 3, 0), (-2, 3, 0), (0, 0, 0)),
			((30, 3, 0), (0, 3, 0), (0, 0, 0)),
			]:
			p, N = cyl.closest_point_to(point)
			self.assertVector(p, closest)
			self.assertVector(N, normal)
Пример #4
0
 def test_cyl_closest_pt_to(self):
     from lepton.domain import Cylinder
     from lepton.particle_struct import Vec3
     cyl = Cylinder((-2, 3, 0), (0, 3, 0), 3, 2)
     for point, closest, normal in [
         ((-1, 7, 0), (-1, 6, 0), (0, 1, 0)),
         ((-2, 3, -6), (-2, 3, -3), (0, 0, -1)),
         ((0, 6, 3), Vec3(0, 3, 0) + Vec3(0, 1, 1).normalize() * 3,
          Vec3(0, 1, 1).normalize()),
         ((-2.2, 5.5, 0), (-2, 5.5, 0), (-1, 0, 0)),
         ((-5, 10, 0), (-2, 6, 0), (-1, 0, 0)),
         ((-10, 3, 1), (-2, 3, 2), (-1, 0, 0)),
         ((0.5, 0, 0), (0, 0, 0), (1, 0, 0)),
         ((3, 5, 0), (0, 5, 0), (1, 0, 0)),
         ((20, 3, -0.1), (0, 3, -2), (1, 0, 0)),
             # points inside cylinder and along axis
         ((-0.5, 5.5, 0), (-0.5, 5.5, 0), (0, 0, 0)),
         ((-1, 3, 0), (-1, 3, 0), (0, 0, 0)),
         ((-30, 3, 0), (-2, 3, 0), (0, 0, 0)),
         ((30, 3, 0), (0, 3, 0), (0, 0, 0)),
     ]:
         p, N = cyl.closest_point_to(point)
         self.assertVector(p, closest)
         self.assertVector(N, normal)