def test_line_starts_in_rectangle(self): l=Line(3,4, 10,3) r=Rect(0,0,5,5) p=Point(0,0) self.assertEquals(line_intersects_rectangle(l,r,p),True) self.assertEquals(p.x,3) self.assertEquals(p.y,4)
def test_line_intersects_rectangle_bottom(self): l=Line(2,-10, 3,10) r=Rect(0,0, 5,5) p=Point(0,0) self.assertEquals(line_intersects_rectangle(l,r,p),True) self.assertEquals(p.x,2.5) self.assertEquals(p.y,0)
def test_line_intersects_rectangle_side(self): l=Line(0,1, 10,3) r=Rect(5,0, 5,5) p=Point(0,0) self.assertEquals(line_intersects_rectangle(l,r,p),True) self.assertEquals(p.x,5) self.assertEquals(p.y,2)
def test_line_intersects_rectangle_top(self): l=Line(2,10, 2,3) r=Rect(0,0, 5,5) p=Point(0,0) self.assertEquals(line_intersects_rectangle(l,r,p),True) self.assertEquals(p.x,2) self.assertEquals(p.y,5)
def test_line_starts_in_rectangle(self): l = Line(3, 4, 10, 3) r = Rect(0, 0, 5, 5) p = Point(0, 0) self.assertEquals(line_intersects_rectangle(l, r, p), True) self.assertEquals(p.x, 3) self.assertEquals(p.y, 4)
def test_line_intersects_rectangle_bottom(self): l = Line(2, -10, 3, 10) r = Rect(0, 0, 5, 5) p = Point(0, 0) self.assertEquals(line_intersects_rectangle(l, r, p), True) self.assertEquals(p.x, 2.5) self.assertEquals(p.y, 0)
def test_line_intersects_rectangle_top(self): l = Line(2, 10, 2, 3) r = Rect(0, 0, 5, 5) p = Point(0, 0) self.assertEquals(line_intersects_rectangle(l, r, p), True) self.assertEquals(p.x, 2) self.assertEquals(p.y, 5)
def test_line_intersects_rectangle_side(self): l = Line(0, 1, 10, 3) r = Rect(5, 0, 5, 5) p = Point(0, 0) self.assertEquals(line_intersects_rectangle(l, r, p), True) self.assertEquals(p.x, 5) self.assertEquals(p.y, 2)
def test_line_doesnt_intersect_rectangle(self): l=Line(2,-10, 3,10) r=Rect(5,5, 5,5) self.assertEquals(line_intersects_rectangle(l,r),False)
def test_line_doesnt_intersect_rectangle(self): l = Line(2, -10, 3, 10) r = Rect(5, 5, 5, 5) self.assertEquals(line_intersects_rectangle(l, r), False)