pub fn seg_closest_point<T>(
    v1: PlineVertex<T>,
    v2: PlineVertex<T>,
    point: Vector2<T>,
    epsilon: T
) -> Vector2<T>
where T: Real,
Expand description

Find the closest point on a polyline segment defined by v1 to v2 to point given. If there are multiple closest points then one is chosen (which is chosen is not defined).

epsilon is used for fuzzy float comparisons.

§Examples

// counter clockwise half circle arc going from (2, 2) to (2, 4)
let v1 = PlineVertex::new(2.0, 2.0, 1.0);
let v2 = PlineVertex::new(4.0, 2.0, 0.0);
assert!(
    seg_closest_point(v1, v2, Vector2::new(3.0, 0.0), 1e-5).fuzzy_eq(Vector2::new(3.0, 1.0))
);
assert!(
    seg_closest_point(v1, v2, Vector2::new(3.0, 1.2), 1e-5).fuzzy_eq(Vector2::new(3.0, 1.0))
);
assert!(seg_closest_point(v1, v2, v1.pos(), 1e-5).fuzzy_eq(v1.pos()));
assert!(seg_closest_point(v1, v2, v2.pos(), 1e-5).fuzzy_eq(v2.pos()));