Esempio n. 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))
Esempio n. 2
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))
Esempio n. 3
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))
Esempio n. 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))
Esempio n. 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))
Esempio n. 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))
Esempio n. 7
0
    def test_coincident(self):
        p1 = (0.0, 0.0)
        p2 = (10.0, 10.0)

        self.assertEqual(GeometryTools.lineIntersection(p1, p2, p1, p2), (5.0, 5.0))
Esempio n. 8
0
    def test_coincident(self):
        p1 = (0.0, 0.0)
        p2 = (10.0, 10.0)

        self.assertIsNone( GeometryTools.lineIntersection(p1, p2, p1, p2) )
Esempio n. 9
0
    def test_coincident(self):
        p1 = (0.0, 0.0)
        p2 = (10.0, 10.0)

        self.assertIsNone(GeometryTools.lineIntersection(p1, p2, p1, p2))
Esempio n. 10
0
    def test_coincident(self):
        p1 = (0.0, 0.0)
        p2 = (10.0, 10.0)

        self.assertEqual(GeometryTools.lineIntersection(p1, p2, p1, p2),
                         (5.0, 5.0))