Line & Segment Intersection

Drag the endpoints — watch the orientation tests and the intersection point update live.

Pair test: O(1) All-pairs brute: O(n²) Sweep line: O((n+k) log n)
Segment 1 (P1→P2) Segment 2 (P3→P4) Intersection point

Result

Orientation Tests

Testcrosssignmeaning

Proper crossing ⇔ o1≠o2 AND o3≠o4. A zero sign means an endpoint lies on the other line (boundary case).

Complexity Reference

OperationTime
cross / orientationO(1)
do 2 segments intersectO(1)
compute the point (Cramer)O(1)
all-pairs brute forceO(n²)
all intersections (sweep)O((n+k) log n)

Log