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.

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.

Common questions

How do I use this point to line segment distance calculator?

Find the shortest distance from a point to a finite segment and locate the closest point. Enter point x, point y, segment start x, segment start y, segment end x, segment end y. The starting example is editable; use values for the same system or project.

Which assumptions affect this result?

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

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