def test_edges(): rect = Rect(10, 10, 20, 20) edges = [ LineSegment((10, 10), (30, 10)), LineSegment((30, 10), (30, 30)), LineSegment((30, 30), (10, 30)), LineSegment((10, 30), (10, 10)), ] for i in range(4): assert edges[i] == rect.edges[i], "Asserting: "+str(edges[i] == rect.edges[i])#str(edges[i])+" "+str(rect.edges[i])
def test_intersect_line5(): line = LineSegment(Vector2(0, 5), Vector2(13, 5)) rect = Rect(5, 0, 11, 11) assert rect.intersect_line(line) == Vector2(5, 5)
def test_intersect_line3(): line = LineSegment(Vector2(0, 0), Vector2(3, 3)) rect = Rect(5, 5, 11, 11) assert rect.intersect_line(line) is None
def test_intersect_line4(): line = LineSegment(Vector2(0, 0), Vector2(-5, -5)) rect = Rect(-5, -5, 11, 11) assert rect.intersect_line(line) == Vector2(-5, -5)
def test_equation(): l = LineSegment(Vector2(0, 0), Vector2(1, 1)) assert l.equation() == (1, 0)
def test_intersect_line(): line = LineSegment(Vector2(0, 0), Vector2(10, 10)) rect = Rect(5, 5, 11, 11) assert rect.intersect_line(line) == Vector2(5, 5)
def test_intersection3(): l = LineSegment(Vector2(0, 5), Vector2(1, 5)) l2 = LineSegment(Vector2(10, 0), Vector2(10, 10)) assert l.intersection_point(l2) is None
def test_compare(): l = LineSegment(Vector2(0, 0), Vector2(100, 100)) l2 = LineSegment(Vector2(0, 0), Vector2(100, 100)) assert l == l2
def test_intersection2(): l = LineSegment(Vector2(0, 5), Vector2(12, 5)) l2 = LineSegment(Vector2(10, 0), Vector2(10, 10)) assert l.intersection_point(l2) == Vector2(10, 5)
def test_intersection_false(): l = LineSegment(Vector2(0, 0), Vector2(0, 100)) l2 = LineSegment(Vector2(10, 0), Vector2(10, 1)) assert l.intersection_point(l2) is None
def test_intersection_par(): l = LineSegment(Vector2(0, 0), Vector2(1, 1)) l2 = LineSegment(Vector2(1, 1), Vector2(2, 2)) assert l.intersection_point(l2) is None
def test_intersection_real(): l = LineSegment(Vector2(0., 0.), Vector2(1., 1.)) l2 = LineSegment(Vector2(0., 1.), Vector2(1., 0.)) assert l.intersection_point(l2) == Vector2(0.5, 0.5)
def test_equation2(): l = LineSegment(Vector2(1, 0), Vector2(1, 5)) assert l.equation() is not None