Geometry

Point to Line Segment Distance Calculator

Find the shortest distance from a point to a finite segment and locate the closest point.

Use consistent dimensionsArea and volume units explained below
Coordinate workspace
Coordinate workspace

The segment endpoints limit the projection; a closest point may be an endpoint.

See the method

Set the point and segment

Runs on your device

Closest-point result

Your result

Let’s calculate.

Use the Calculate button to see your result.

Review the method below for assumptions and conventions.

How to use this tool

  1. Enter point x, point y, segment start x, segment start y, segment end x, segment end y.
  2. Select Calculate to view the result.
  3. Check the method and assumptions below before using the result.

Input reference and sample values

Use the units and choices shown for each field. Sample values are provided for practice, not as recommendations.

InputFormat and unitsSample
Point xNumeric value.3
Point yNumeric value.4
Segment start xNumeric value.0
Segment start yNumeric value.0
Segment end xNumeric value.2
Segment end yNumeric value.0

Result for these sample inputs

4.12310563 units
Closest point
(2, 0)
Segment parameter
1

Select Try the example in the form to load these values and calculate them again. This replaces the current form inputs. Compare the result with the method and worked explanation below.

The method, explained

Project AP onto AB and clamp the parameter t to [0,1]. Distance is from P to A+t(B−A).

A WORKED EXAMPLE

Using point x = 3, point y = 4, segment start x = 0, segment start y = 0, segment end x = 2, segment end y = 0, the result is 4.12310563 units. Change these example inputs to match your task; use the method above to check each step.

Understanding your result

Unlike distance to an infinite line, the closest point can be an endpoint. A zero-length segment is treated as a point.

What to keep in mind

Unlike distance to an infinite line, the closest point can be an endpoint. A zero-length segment is treated as a point. Use the indicated units consistently. Ideal shapes are assumed; dimensions must describe the same object. Display rounding does not increase measurement precision.

Methodology maintained by ClarityKit. How these tools are built and checked.