示例#1
0
    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)
示例#2
0
    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)
示例#3
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)
示例#4
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)
示例#5
0
    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)
示例#6
0
    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)
示例#7
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)
示例#8
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)
示例#9
0
    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)
示例#10
0
    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)