Skip to main content

Module segment_intersection

Module segment_intersection 

Source
Expand description

OVL1.T3 — segment-segment intersection.

The central kernel of overlay: given two segments, report whether they are disjoint, meet at a single point, or overlap along a collinear stretch — and where.

Mirrors boost/geometry/algorithms/detail/overlay/get_intersection_points.hpp and boost/geometry/strategy/cartesian/intersection.hpp. Boost’s strategy returns a rich segment_intersection_points structure with zero, one, or two points plus fraction metadata; the port returns the three-way SegmentIntersection enum, which carries the same information overlay needs (how many points, and their coordinates).

§Method

Classification is done entirely with the exact-sign orientation_2d predicate (four side tests), matching Boost’s use of side_by_triangle to decide the case before computing any coordinate. Only once a proper crossing is confirmed is the intersection point computed, by solving the two parametric line equations. Every endpoint is first routed through coordinate_in_range so the sign tests are exact; an out-of-range endpoint yields SegmentIntersection::OutOfRange.

Enums§

SegmentIntersection
The outcome of intersecting two segments.

Functions§

segment_intersection
Intersect two segments a and b.