pub fn closest_segments2(
first_start: Vec2,
first_end: Vec2,
second_start: Vec2,
second_end: Vec2,
) -> Result<ClosestPoints<2>, SegmentError>Expand description
Finds closest points on two finite ordered 2D segments, including crossings, parallel overlap and point segments. Equal computed squared separations prefer the lowest first parameter, then the lowest second parameter.
use ferravex_math::{Vec2, vec2};
use ferravex_math::segments::closest_segments2;
let hit = closest_segments2(Vec2::ZERO, Vec2::X * 4., vec2(2., 0.), vec2(6., 0.))?;
assert_eq!((hit.first_parameter, hit.second_parameter), (0.5, 0.));
assert_eq!(hit.first, hit.second);
assert_eq!(hit.distance, 0.);