Ejemplo n.º 1
0
    def test_solid_disc_intersect(self):
        from lepton.domain import Disc
        from lepton.particle_struct import Vec3
        normal = Vec3(1, 1, 0).normalize()
        disc = Disc((-2, 0, 1), normal, 1)
        lines = [
            ((-5, 0, 0), (5, 0, 0)),
            ((-2, 1, 1), (-2, -1, 1)),
            ((3, normal.y, 1), (-3, normal.y, 1)),
        ]
        expected = [
            ((-2, 0, 0), -normal),
            ((-2, 0, 1), normal),
            ((-2 - normal.x, normal.y, 1), normal),
        ]

        for (start, end), (point, normal) in zip(lines, expected):
            p, N = disc.intersect(start, end)
            self.assertVector(p, point)
            self.assertVector(N, normal)

            # Reverse direction should yield same point and inverse normal
            p, N = disc.intersect(end, start)
            self.assertVector(p, point)
            self.assertVector(N, -Vec3(*normal))
Ejemplo n.º 2
0
    def test_hollow_disc_intersect(self):
        from lepton.domain import Disc
        from lepton.particle_struct import Vec3
        disc = Disc((2, 2, 2), (0, 1, 0), 3, 1)
        lines = [
            ((-1, 3, 2), (-1, 0, 2)),
            ((1, 3, 0), (1, 0, 0)),
            ((2, 5, 4), (2, -5, 4)),
            ((3, 1, 2), (5, 3, 2)),
        ]
        expected = [
            ((-1, 2, 2), (0, 1, 0)),
            ((1, 2, 0), (0, 1, 0)),
            ((2, 2, 4), (0, 1, 0)),
            ((4, 2, 2), (0, -1, 0)),
        ]

        for (start, end), (point, normal) in zip(lines, expected):
            p, N = disc.intersect(start, end)
            self.assertVector(p, point)
            self.assertVector(N, normal)

            # Reverse direction should yield same point and inverse normal
            p, N = disc.intersect(end, start)
            self.assertVector(p, point)
            self.assertVector(N, -Vec3(*normal))
Ejemplo n.º 3
0
	def test_hollow_disc_intersect(self):
		from lepton.domain import Disc
		from lepton.particle_struct import Vec3
		disc = Disc((2,2,2), (0,1,0), 3, 1)
		lines = [
			((-1, 3, 2), (-1, 0, 2)),
			((1, 3, 0), (1, 0, 0)),
			((2, 5, 4), (2, -5, 4)),
			((3, 1, 2), (5, 3, 2)),
		]
		expected = [
			((-1, 2, 2), (0,1,0)),
			((1, 2, 0), (0,1,0)),
			((2, 2, 4), (0,1,0)),
			((4, 2, 2), (0,-1,0)),
		]

		for (start, end), (point, normal) in zip(lines, expected):
			p, N = disc.intersect(start, end)
			self.assertVector(p, point)
			self.assertVector(N, normal)

			# Reverse direction should yield same point and inverse normal
			p, N = disc.intersect(end, start)
			self.assertVector(p, point)
			self.assertVector(N, -Vec3(*normal))
Ejemplo n.º 4
0
	def test_solid_disc_intersect(self):
		from lepton.domain import Disc
		from lepton.particle_struct import Vec3
		normal = Vec3(1, 1, 0).normalize()
		disc = Disc((-2, 0, 1), normal, 1)
		lines = [
			((-5, 0, 0), (5, 0, 0)),
			((-2, 1, 1), (-2, -1, 1)),
			((3, normal.y, 1), (-3, normal.y, 1)),
		]
		expected = [
			((-2, 0, 0), -normal),
			((-2, 0, 1), normal),
			((-2 - normal.x, normal.y, 1), normal),
		]

		for (start, end), (point, normal) in zip(lines, expected):
			p, N = disc.intersect(start, end)
			self.assertVector(p, point)
			self.assertVector(N, normal)

			# Reverse direction should yield same point and inverse normal
			p, N = disc.intersect(end, start)
			self.assertVector(p, point)
			self.assertVector(N, -Vec3(*normal))
Ejemplo n.º 5
0
	def test_hollow_disc_no_intersect(self):
		from lepton.domain import Disc
		disc = Disc((2,2,2), (0,1,0), 3, 1)
		for start, end in [
			((2, 3, 2.5), (2, 0, 1.5)),
			((2, 2, 2), (5, 2, 2)),
			((-2, 10, 20), (-5, 15, 19))]:
			self.assertEqual(
				disc.intersect(start, end), (None, None))
			self.assertEqual(
				disc.intersect(end, start), (None, None))
Ejemplo n.º 6
0
	def test_solid_disc_no_intersect(self):
		from lepton.domain import Disc
		disc = Disc((0, 0, 0), (1, 0, 0), 1)
		for start, end in [
			((1, 0, 0), (2, 0, 0)),
			((0, 0, 0), (0, 1, 0)),
			((-2, 10, 20), (-5, 15, 19))]:
			self.assertEqual(
				disc.intersect(start, end), (None, None))
			self.assertEqual(
				disc.intersect(end, start), (None, None))
Ejemplo n.º 7
0
 def test_hollow_disc_no_intersect(self):
     from lepton.domain import Disc
     disc = Disc((2, 2, 2), (0, 1, 0), 3, 1)
     for start, end in [((2, 3, 2.5), (2, 0, 1.5)), ((2, 2, 2), (5, 2, 2)),
                        ((-2, 10, 20), (-5, 15, 19))]:
         self.assertEqual(disc.intersect(start, end), (None, None))
         self.assertEqual(disc.intersect(end, start), (None, None))
Ejemplo n.º 8
0
 def test_solid_disc_no_intersect(self):
     from lepton.domain import Disc
     disc = Disc((0, 0, 0), (1, 0, 0), 1)
     for start, end in [((1, 0, 0), (2, 0, 0)), ((0, 0, 0), (0, 1, 0)),
                        ((-2, 10, 20), (-5, 15, 19))]:
         self.assertEqual(disc.intersect(start, end), (None, None))
         self.assertEqual(disc.intersect(end, start), (None, None))