Example #1
0
    def test_arbitrary_lines_interserct(self):
        l1=Line(0,0,10,10)
        l2=Line(0,4,10,6)
        p=Point(0,0)

        self.assertEquals(line_intersects_line(l1,l2,p),True)
        self.assertEquals(p.x,5)
        self.assertEquals(p.y,5)
Example #2
0
 def test_orthoganal_perpendicular_lines_intersect(self):
     l1=Line(0,1,10,1)
     l2=Line(2,5,2,-5)
     p=Point(0,0)
     
     self.assertEquals(line_intersects_line(l1,l2,p),True)
     self.assertEquals(p.x, 2)
     self.assertEquals(p.y, 1)
Example #3
0
    def test_colinear_parallel_lines_dont_intersect(self):
        l1=Line(1,1,4,4)
        l2=Line(10,10,8,8)
        p=Point(0,0)

        self.assertEquals(line_intersects_line(l1,l2,p),False)
        self.assertEquals(p.x,0)
        self.assertEquals(p.y,0)
Example #4
0
    def test_parallel_lines_dont_intersect(self):
        l1=Line(1,1,5,6)
        l2=Line(1,2,5,7)
        p=Point(0,0)

        self.assertEquals(line_intersects_line(l1,l2,p),False)
        self.assertEquals(p.x,0)
        self.assertEquals(p.y,0)
Example #5
0
    def test_perpendicular_lines_dont_intersect(self):
        l1=Line(0,0,10,10)
        l2=Line(0,10,3,7)
        p=Point(0,0)

        self.assertEquals(line_intersects_line(l1,l2,p),False)
        self.assertEquals(p.x,0)
        self.assertEquals(p.y,0)
Example #6
0
    def test_parallel_lines_intersect(self):
        l1=Line(7,10,0,0)
        l2=Line(3.5,5,0,0)
        p=Point(0,0)

        self.assertEquals(line_intersects_line(l1,l2,p),True)
        self.assertEquals(p.x,3.5)
        self.assertEquals(p.y,5)