Detecting line segment intersections using the sweepline algorithm in Python.