Example #1
0
    def test_intersection(self):

        p1 = (0.0, 0.0)
        p2 = (10.0, 0.0)
        p3 = (5.0, -5.0)
        p4 = (5.0, 5.0)

        self.assertEqual(GeometryTools.lineIntersection(p1, p2, p3, p4), (5.0, 0.0))

        p5 = (0.0, 5.0)
        self.assertEqual(GeometryTools.lineIntersection(p1, p2, p3, p5), (2.5, 0))


        self.assertEqual(GeometryTools.lineIntersection((0.0, 0.0), (1.0, 1.0), (0.0, 1.0), (1.0, 0.0)), (0.5, 0.5))
Example #2
0
    def test_intersection_outside_segments(self):
        p1 = (0.0, 0.0)
        p2 = (10.0, 0.0)

        p3 = (-1.0, -1.0)
        p4 = (-1.0, 1.0)

        self.assertIsNone(GeometryTools.lineIntersection(p1, p2, p3, p4))
Example #3
0
    def test_parallel(self):
        p1 = (0.0, 0.0)
        p2 = (10.0, 0.0)

        p3 = (0.0, 1.0)
        p4 = (10.0, 1.0)

        self.assertIsNone(GeometryTools.lineIntersection(p1, p2, p3, p4))
Example #4
0
    def test_intersection(self):

        p1 = (0.0, 0.0)
        p2 = (10.0, 0.0)
        p3 = (5.0, -5.0)
        p4 = (5.0, 5.0)

        self.assertEqual(GeometryTools.lineIntersection(p1, p2, p3, p4),
                         (5.0, 0.0))

        p5 = (0.0, 5.0)
        self.assertEqual(GeometryTools.lineIntersection(p1, p2, p3, p5),
                         (2.5, 0))

        self.assertEqual(
            GeometryTools.lineIntersection((0.0, 0.0), (1.0, 1.0), (0.0, 1.0),
                                           (1.0, 0.0)), (0.5, 0.5))
Example #5
0
    def test_intersection_outside_segments(self):
        p1 = (0.0, 0.0)
        p2 = (10.0, 0.0)

        p3 = (-1.0, -1.0)
        p4 = (-1.0, 1.0)

        self.assertIsNone(GeometryTools.lineIntersection(p1, p2, p3, p4))
Example #6
0
    def test_parallel(self):
        p1 = (0.0, 0.0)
        p2 = (10.0, 0.0)

        p3 = (0.0, 1.0)
        p4 = (10.0, 1.0)

        self.assertIsNone(GeometryTools.lineIntersection(p1, p2, p3, p4))
Example #7
0
    def test_coincident(self):
        p1 = (0.0, 0.0)
        p2 = (10.0, 10.0)

        self.assertIsNone(GeometryTools.lineIntersection(p1, p2, p1, p2))
Example #8
0
    def test_coincident(self):
        p1 = (0.0, 0.0)
        p2 = (10.0, 10.0)

        self.assertIsNone( GeometryTools.lineIntersection(p1, p2, p1, p2) )