Why it matters
Segment intersection is classic sweep. Understanding shapes technique.
Advertisement
The architecture
Sweep line events: endpoints + intersections.
Active: BBST by y at sweep.
Check neighbors for intersection.
Advertisement
How it works end to end
Insert start, remove end, swap on intersection.
Only adjacent pairs can intersect next.
Add intersections to event PQ.