def test_basic_polygon_intersect(self): poly = Polygon() poly.add_point(0, 0) poly.add_point(0, 1) poly.add_point(1, 1) poly.add_point(1, 0) line = [Vec2d(-0.5, -0.5), Vec2d(0.5, 0.5)] self.assertTrue(intersect_polygon(line, poly)) line = [Vec2d(1, -1), Vec2d(1, 0)] self.assertFalse(intersect_polygon(line, poly))
def test_border_non_intersect(self): polygon = Polygon() polygon.add_point(0, 0) polygon.add_point(0, 1) polygon.add_point(1, 1) polygon.add_point(1, 0) line1 = [Vec2d(0, 0), Vec2d(1, 0)] self.assertFalse(intersect_polygon(line1, polygon))