Skip to main content

point_to_line_distance

Function point_to_line_distance 

Source
pub fn point_to_line_distance(
    point: Pos2,
    line_start: Pos2,
    line_end: Pos2,
) -> f32
Expand description

Calculates the perpendicular distance from point to the closest point on the line segment [line_start, line_end].

The projection is clamped to the segment endpoints. Returns the Euclidean distance to line_start if the segment is degenerate (zero-length).