Skip to main content

segment_intersection

Function segment_intersection 

Source
fn segment_intersection(
    a0: Vec2,
    a1: Vec2,
    b0: Vec2,
    b1: Vec2,
    tolerance: f32,
) -> Option<(f32, f32, Vec2)>
Expand description

Robust-ish two-segment intersection. Returns (t_along_first, t_along_second, intersection_point) when the segments cross in the interior of both. Endpoint-only touches are filtered out by the caller via t > tolerance && t < 1 - tolerance. Returns None for parallel, collinear, or near-collinear pairs.