Ejemplo n.º 1
0
    def test_all_others(self):
        s = Spherical(Vector3D(0, 0, 0), 3)
        c = Cuboid(Vector3D(0, 0, 0), Vector3D(0, 0, 0), 1, 1, 1)

        it_1 = intersect(All(), s)
        it_2 = intersect(All(), c)

        self.assertEqual(it_1, s)
        self.assertEqual(it_2, c)
Ejemplo n.º 2
0
    def test_others_all(self):
        s = Spherical(Vector3D(0, 0, 0), 3)
        c = Cuboid(Vector3D(0, 0, 0), Vector3D(0, 0, 0), 1, 1, 1)

        it_1 = intersect(s, All())
        it_2 = intersect(c, All())

        self.assertEqual(it_1, s)
        self.assertEqual(it_2, c)
Ejemplo n.º 3
0
    def test_halfspace_convpolyh_noIntersection(self):
        hs = HalfSpace(Vector3D(0, 4, 0), Vector3D(0, 1, 0))
        cp = ConvexPolyhedron(
            to_hsi(Cuboid(Vector3D(0.0, 0.0, 0.0), Vector3D(0, 0, 0), 1, 1,
                          1)))
        it = intersect(hs, cp)

        self.assertTrue(isinstance(it, Empty))
Ejemplo n.º 4
0
    def test_halfspace_halfspace_same(self):
        hs_1 = HalfSpace(Vector3D(0, 0, 0), Vector3D(0, 1, 0))
        hs_2 = HalfSpace(Vector3D(0, 0, 0), Vector3D(0, 1, 0))
        it = intersect(hs_1, hs_2)

        self.assertTrue(isinstance(it, ConvexPolyhedron))

        self.assertTrue(contains_point(hs_1, Vector3D(*it.hsi.interior_point)))
        self.assertTrue(contains_point(hs_2, Vector3D(*it.hsi.interior_point)))
Ejemplo n.º 5
0
    def test_halfspace_convpolyh_intersection(self):
        hs = HalfSpace(Vector3D(0, 1, 0), Vector3D(0, 1, 0))
        cp = ConvexPolyhedron(
            to_hsi(Cuboid(Vector3D(0.0, 0.0, 0.0), Vector3D(0, 0, 0), 5, 5,
                          5)))
        it = intersect(hs, cp)

        self.assertTrue(isinstance(it, ConvexPolyhedron))
        self.assertTrue(contains_point(hs, Vector3D(*it.hsi.interior_point)))
        self.assertTrue(contains_point(cp, Vector3D(*it.hsi.interior_point)))
Ejemplo n.º 6
0
    def test_halfspace_convpg_noIntersection(self):
        hs = HalfSpace(Vector3D(0, 4, 0), Vector3D(0, 1, 0))
        hsi = HalfspaceIntersection(
            np.array([[1, 0, -3], [0, 1, -3], [-1, 0, 0], [0, -1, 0]]),
            np.array([1.0, 1.0]))
        cp = ConvexPolygon3D(hsi=hsi,
                             origin=Vector3D(0, 0, 0),
                             rot=Vector3D(0, 0, 0))
        it = intersect(hs, cp)

        self.assertTrue(isinstance(it, Empty))
Ejemplo n.º 7
0
    def test_halfspace_convpg_intersection(self):
        hs = HalfSpace(Vector3D(0, 2, 0), Vector3D(0, 1, 0))
        hsi = HalfspaceIntersection(
            np.array([[1, 0, -3], [0, 1, -3], [-1, 0, 0], [0, -1, 0]]),
            np.array([1.0, 1.0]))
        cp = ConvexPolygon3D(hsi=hsi,
                             origin=Vector3D(0, 0, 0),
                             rot=Vector3D(0, 0, 0))
        it = intersect(hs, cp)

        int_point_3d: Vector3D = rotate_euler_v3d(
            Vector3D(*it.hsi.interior_point, 0.0), it.rot) + it.origin

        self.assertTrue(isinstance(it, ConvexPolygon3D))
        self.assertTrue(contains_point(hs, int_point_3d))
        self.assertTrue(contains_point(cp, int_point_3d))
Ejemplo n.º 8
0
 def test_others_empty(self):
     s = Spherical(Vector3D(0, 0, 0), 3)
     c = Cuboid(Vector3D(0, 0, 0), Vector3D(0, 0, 0), 1, 1, 1)
     self.assertEqual(Empty(), intersect(s, Empty()))
     self.assertEqual(Empty(), intersect(c, Empty()))
Ejemplo n.º 9
0
 def test_empty_others(self):
     s = Spherical(Vector3D(0, 0, 0), 3)
     c = Cuboid(Vector3D(0, 0, 0), Vector3D(0, 0, 0), 1, 1, 1)
     self.assertEqual(Empty(), intersect(Empty(), s))
     self.assertEqual(Empty(), intersect(Empty(), c))
Ejemplo n.º 10
0
 def test_empty_empty(self):
     self.assertEqual(Empty(), intersect(Empty(), Empty()))
Ejemplo n.º 11
0
 def test_empty_all(self):
     self.assertEqual(Empty(), intersect(Empty(), All()))
Ejemplo n.º 12
0
 def test_all_empty(self):
     it = intersect(All(), Empty())
     self.assertEqual(Empty(), it)
Ejemplo n.º 13
0
 def test_all_all(self):
     it = intersect(All(), All())
     self.assertEqual(All(), it)
Ejemplo n.º 14
0
    def test_halfspace_halfspace_noIntersectionByDistance(self):
        hs_1 = HalfSpace(Vector3D(0, 1, 0), Vector3D(0, 1, 0))
        hs_2 = HalfSpace(Vector3D(0, 10000, 0), Vector3D(0, 1, 0))
        it = intersect(hs_1, hs_2)

        self.assertTrue(isinstance(it, Empty))