def test_line_segment_point_intersection_up_down(): """A single point intersection""" ls1 = LineSegment(Point(0, -4), Point(0, 4)) ls2 = LineSegment(Point(0, 2), Point(0, -2)) expected = LineSegment(Point(0, -2), Point(0, 2)) assert ls1.intersect(ls2).simplify() == expected assert ls2.intersect(ls1).simplify() == expected
def test_line_segment_intersection_90_270(): """A single point intersection""" ls1 = LineSegment(Point(0, 0), Point(0, 1)) ls2 = LineSegment(Point(0, 3), Point(0, 1)) assert ls1.intersect(ls2) == Point(0, 1) assert ls2.intersect(ls1) == Point(0, 1)
def test_line_segment_no_intersection2(): """No intersection""" ls1 = LineSegment(Point(0, 0), Point(0, 1)) ls2 = LineSegment(Point(0, 2), Point(0, 3)) assert ls1.intersect(ls2) is None assert ls2.intersect(ls1) is None
def test_line_segment_no_intersection1(): """No intersection""" ls1 = LineSegment(Point(0, 0), Point(1, 0)) ls2 = LineSegment(Point(2, 0), Point(3, 0)) assert ls1.intersect(ls2) is None assert ls2.intersect(ls1) is None
def test_line_segment_point_intersection_horizontal_vertical_cross(): """A single point intersection""" ls1 = LineSegment(Point(-4, 0), Point(4, 0)) ls2 = LineSegment(Point(0, -4), Point(0, 4)) assert ls1.intersect(ls2) == Point(0, 0) assert ls2.intersect(ls1) == Point(0, 0)
def test_line_segment_point_intersection4(): """A single point intersection""" ls1 = LineSegment(Point(0, 4), Point(20, 4)) ls2 = LineSegment(Point(0, 0), Point(20, 20)) assert ls1.intersect(ls2) == Point(4, 4) assert ls2.intersect(ls1) == Point(4, 4)
def test_line_segment_point_intersection1(): """A single point intersection""" ls1 = LineSegment(Point(0, 0), Point(1, 1)) ls2 = LineSegment(Point(1, 1), Point(3, 3)) assert ls1.intersect(ls2).simplify() == Point(1, 1) assert ls2.intersect(ls1).simplify() == Point(1, 1)