StatGardenREF. DESK
Calculators/Maths/Distance from a point to a line
Maths

Distance from a point to a line calculator

Perpendicular distance from a point to a line given in general form.

Published 6 August 2026 · Updated 23 September 2026

What this calculator does

The shortest route from a point to a line is always perpendicular to it. With the line written as Ax + By + C = 0, that distance has a remarkably compact formula: substitute the point, take the absolute value, divide by the length of the coefficient vector.

The substitution is doing the work. A point on the line gives exactly zero, and the further the point sits from the line, the larger the substituted value becomes in proportion.

The formula

FormulaLine: Ax + By + C = 0; distance = |Ax₀ + By₀ + C| / √(A² + B²)

The point coordinates are substituted into the line equation. Taking the absolute value and dividing by the square root of A squared plus B squared gives the perpendicular distance.

TermMeaning
General formAx + By + C = 0, which handles vertical lines that y = mx + b cannot.
Foot of the perpendicularThe closest point on the line to the given point.
Normal vectorThe vector (A, B), which points perpendicular to the line.

The inputs explained

FieldWhat to enter
AThe x coefficient in the line equation.
BThe y coefficient. A and B cannot both be zero.
CThe constant term.
Point x₀The x coordinate of the point.
Point y₀The y coordinate of the point.

When to use it

Finding clearance from a boundary

The perpendicular distance is the shortest gap to a straight edge.

Checking whether a point lies on a line

A distance of zero settles it exactly.

Computer graphics and collision

Point to line distance is a fundamental geometric primitive.

Worked examples

Every figure in the tables below is produced by this page’s own calculator at build time, so the numbers and the tool always agree. Select any row to load that scenario.

How does distance grow along the x axis?

Four points with y = 0 at increasing x.

Line x − y − 2 = 0, points on the x axis
Point x (y = 0)DistancePoint is on the line?
(0, 0)1.414No
(2, 0)0Yes
(6, 0)2.828No
(10, 0)5.657No
The point (2, 0) satisfies the equation exactly and returns a distance of 0. Moving out to (6, 0) gives 2.828 and (10, 0) gives 5.657, each step of 4 in x adding the same 2.828 to the distance.

Questions

Why divide by the square root of A squared plus B squared?

Because (A, B) is the normal vector to the line, and dividing by its length normalises it. Without that division the result would scale with however the equation happened to be written, since 2x − 2y − 4 = 0 describes the same line.

How do I convert y = mx + b to general form?

Rearrange to mx − y + b = 0, so A is the slope, B is −1 and C is the intercept. Any line in slope-intercept form converts this way in one step.

What does the sign mean before the absolute value?

Which side of the line the point sits on. Points on opposite sides give opposite signs, which is useful for testing whether two points are on the same side without computing distances.

Does this work in three dimensions?

Not directly. In 3D the same equation form describes a plane rather than a line, and point to line distance in space requires a different approach using the cross product.

For the line equation itself, see the line equation calculator. For distance to a plane in 3D, see the point to plane distance calculator.