Segment Intersection Algorithm

Hoey algorithm apply this principle to solve the line segment intersection detection problem, as stated above, of determine whether or not a set of line sections has an intersection; the Bentley – Ottmann algorithm works by the same principle to list all intersections in logarithmic time per intersection. The most common, and more efficient, way to solve this problem for a high number of sections is to use a sweep line algorithm, where we imagine a line sliding across the line sections and we track

Segment Intersection source code, pseudocode and analysis