Segment Intersection by Orientation and Bounds

Classify a proper two-segment crossing and handle collinear overlap with exact endpoint conventions.

Source
Anbloq
Language
English
Created
Updated
Chapters
2
Reading time
1 min
In this article2 chapters
  1. The endpoints must straddle both supporting lines
  2. A zero determinant requires a containment test

The endpoints must straddle both supporting lines

For noncollinear endpoint tests, segments \(ab\) and \(cd\) cross properly when \(c,d\) lie on opposite sides of the line through \(a,b\), and \(a,b\) lie on opposite sides of the line through \(c,d\). The two straddles ensure the unique line intersection lies in the interior of each segment. The diagonals of a square satisfy both tests and meet at its center.

A zero determinant requires a containment test

When an endpoint lies on the other line, first decide whether it lies within the closed coordinate bounds of the segment. Collinear segments can overlap, touch at one endpoint or be disjoint. Comparing projected intervals on an axis with nonzero length handles the nondegenerate collinear case. Zero-length segments reduce to point containment. Robust orientation protects the sign decisions. Convex hull construction relies on the same turn convention.[1]

References

  1. Jonathan Richard Shewchuk, Adaptive Precision Floating-Point Arithmetic and Fast Robust Geometric Predicates ↩