distance_point_to_line_segment Function

public function distance_point_to_line_segment(px, py, x1, y1, x2, y2) result(distance)

Calculate minimum distance from point to line segment

Uses parametric line representation and projection to find closest point. For degenerate segments (length < EPSILON_GEOMETRY), returns distance to endpoint.

@param px, py Point coordinates @param x1, y1 Line segment start point @param x2, y2 Line segment end point @return distance Minimum euclidean distance from point to segment

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: px
real(kind=wp), intent(in) :: py
real(kind=wp), intent(in) :: x1
real(kind=wp), intent(in) :: y1
real(kind=wp), intent(in) :: x2
real(kind=wp), intent(in) :: y2

Return Value real(kind=wp)