Exemple #1
0
    def testLineProps(self):
        L1 = Line(Point(0, 0), Point(1, 1))
        L2 = Line(Point(-1, -3), Point(6, 2))
        Lo = Line(Point(2, 2), Point(7, 7))
        Lp = Line(Point(0, -1), Point(1, 0))
        Lr = Line(Point(2, 0), Point(0, 2))
        Lv = Line(Point(1, 2), Point(1, 4))
        Lh = Line(Point(3, 5), Point(-4, 5))

        self.assertFalse(L1.is_horizontal)
        self.assertFalse(L1.is_vertical)
        self.assertTrue(Lv.is_vertical)
        self.assertTrue(Lh.is_horizontal)

        self.assertEqual(Lh.slope, 0)
        self.assertEqual(Lh.intercept, 5)
        self.assertEqual(Lv.slope, float("inf"))
        self.assertEqual(Lv.intercept, 1)

        self.assertEqual(L1.slope, 1)
        self.assertEqual(L1.intercept, 0)

        self.assertFalse(L1.is_overlapping(L2))
        self.assertTrue(L1.is_overlapping(Lo))

        self.assertFalse(L1.is_perpendicular(L2))
        self.assertTrue(L1.is_perpendicular(Lr))

        self.assertFalse(L1.is_parallel(L2))
        self.assertTrue(L1.is_parallel(Lp))
Exemple #2
0
 def testPointOfIntersection(self):
     L1 = Line(Point(0, 0), Point(1, 1))
     L2 = Line(-2, 1, 3)
     p = Point(-3, -3)
     self.assertEqual(L1.point_of_intersection(L2), p)
Exemple #3
0
 def testPerpendicularThroughPoint(self):
     L1 = Line(Point(0, 0), Point(1, 1))
     Lr = Line(Point(2, 0), Point(0, 2))
     p = Point(1, 1)
     self.assertEqual(L1.perpendicular_through_point(p), Lr)
Exemple #4
0
 def testParallelThroughPoint(self):
     L1 = Line(Point(0, 0), Point(1, 1))
     Lp = Line(Point(0, -1), Point(1, 0))
     p = Point(2, 1)
     self.assertEqual(L1.parallel_through_point(p), Lp)