Esempio n. 1
0
 def test_points_in_line(self):
     """
     Test if constructing a plane from points forming a line raises an exception
     """
     with pytest.raises(exceptions.PlaneConstructionError):
         plane = polygons.Plane([[-1] * 3, [0] * 3, [1] * 3, [8] * 3,
                                 [-3] * 3, [50] * 3, [100] * 3, [-10] * 3])
Esempio n. 2
0
 def test_to2D_to3D(self, points, point3d, point2d):
     """
     Test if the conversion to 2D and back to 3D works
     """
     plane = polygons.Plane(points)
     p = plane.to2D(point3d)
     # None as in don't care
     if point2d is not None:
         assert [p.x, p.y] == point2d
     p = plane.to3D(p)
     assert TestPlane.alike(p, point3d)
Esempio n. 3
0
    def test_valid_plane_construction(self, points, result):
        """
        Test if constructing a plane from valid list of points works
        """
        plane = polygons.Plane(points)

        # test only the direction of normal vector and not the size
        planelist = TestPlane.normalize([plane.a, plane.b, plane.c, plane.d])
        result = TestPlane.normalize(result)

        # test for the negative orientation as well
        results = [result, list(map(operator.neg, result))]

        assert planelist in results
Esempio n. 4
0
 def test_longest_recognition(self, points, longest):
     """
     Test if the longest index is well recognized
     """
     plane = polygons.Plane(points)
     assert plane.longest == longest
Esempio n. 5
0
 def test_two_unique_points(self):
     """
     Test if constructing a plane from just two unique points raises an exception
     """
     with pytest.raises(exceptions.PlaneConstructionError):
         plane = polygons.Plane([[0] * 3, [1] * 3] * 10)
Esempio n. 6
0
 def test_all_same_points(self):
     """
     Test if constructing a plane from all points the same raises an exception
     """
     with pytest.raises(exceptions.PlaneConstructionError):
         plane = polygons.Plane([[0] * 3] * 20)
Esempio n. 7
0
 def test_to_few_points(self):
     """
     Test if constructing a plane from two points raises an exception
     """
     with pytest.raises(exceptions.PlaneConstructionError):
         plane = polygons.Plane([[0, 0, 0], [1, 1, 1]])