Your Equation

Library / Geometry, coordinates, surveying and trigonometry / GEO-27

Geometry, coordinates, surveying and trigonometry

Perpendicular distance from a point to a line

Shortest distance from the point (x, y) to the line Ax + By + C = 0.

Ref
GEO-27
Rev
v1
Field
Geometry, coordinates, surveying and trigonometry
Result
d [cm]

The perpendicular distance from the point (x, y) to the line Ax + By + C = 0 is |Ax + By + C| divided by √(A² + B²). The numerator measures how far the point is from satisfying the line equation, and the denominator turns that into a true length. A and B cannot both be zero. It also works for vertical and horizontal lines.

Shortest distance from the point (x, y) to the line Ax + By + C = 0. A and B cannot both be zero. It works for vertical and horizontal lines.

Calculator

Solve for
cm
−66
−66
cm
−2020
cm
−1010
cm
−1010
  • Value of Ax + By + C (signed; its sign gives the side of the line)−5 cm
  • Length of the normal vector, √(A² + B²)5
  • Gradient of the line, −A/B (shown as 0 for a vertical line)−0.75

What drives the result

Each variable is moved across its typical range while the others stay at the values above. The longest bar is the key driver.

Distance to the line (cm) current value 1 cm
yPoint yKey driver
0.06679
xPoint x
0.27
CLine constant C
04
BLine coefficient B
0.7451.67
ALine coefficient A
0.6931.25
  • The point (0, 0) is 1 cm from the line 3x + 4y + (−5) = 0; for 3x + 4y − 5 = 0 the origin is exactly 1 cm away.
  • A signed value tells which side of the line the point is on, which is how a point is tested against a boundary.
Chart data as tables

Ranked variables

VariableTypical rangeLowest resultHighest resultSwing (cm)Local stepChange in result
y Point y−10 to 10 cm0.0666798.933+0.4 cm−32 %
x Point x−10 to 10 cm0.276.8+0.4 cm−24 %
C Line constant C−20 to 20 cm044+0.8 cm−16 %
B Line coefficient B−6 to 6 0.74541.6670.9213+0.24 −3.74 %
A Line coefficient A−6 to 6 0.69341.250.5566+0.24 −2.87 %

Sweep of Line constant C

Line constant C (cm)Distance to the line (cm)
−204
−153
−102
−51
00
51
102
153
204

Sweep one variable

Distance to the line (cm)Hover, touch, or use the arrow keys on the chart
01234 −20−1001020 Line constant C (cm) now 1

Variables and how each one contributes

d

Distance to the line

Result · cm

What the equation gives you. Everything else feeds it.

A

Line coefficient A

· typical −6 to 6

The coefficient of x in the line equation, a plain number. Changes both the slope of the line and the distance, and not in proportion. Raising it by 0.5 (to 3.5) moves the result by −5.93 %, from 1 to 0.9407 cm.

B

Line coefficient B

· typical −6 to 6

The coefficient of y in the line equation, a plain number. Changes both the slope of the line and the distance, and not in proportion. Raising it by 0.5 (to 4.5) moves the result by −7.55 %, from 1 to 0.9245 cm.

C

Line constant C

cm · typical −20 to 20

The constant of the line equation, in cm. Shifts the line, which changes the distance in proportion when the point is on one side. Raising it by 0.5 (to −4.5) moves the result by −10 %, from 1 to 0.9 cm.

x

Point x

cm · typical −10 to 10

The x-coordinate of the point, in cm. Moves the point relative to the line. Raising it by 0.5 (to 0.5) moves the result by −30 %, from 1 to 0.7 cm.

y

Point y

cm · typical −10 to 10

The y-coordinate of the point, in cm. Moves the point relative to the line. Raising it by 0.5 (to 0.5) moves the result by −40 %, from 1 to 0.6 cm.

Worked example with the values above

  1. Substitute into the line: A x + B y + C = 3 × 0 + 4 × 0 + −5 = −5.
  2. Length of the normal: √(A² + B²) = 5.
  3. d = 5 / 5 = 1 cm.

Assumptions and limits

  • Plane (two-dimensional) Cartesian coordinates in one consistent unit.
  • The two points or the two direction vectors are not the same, and neither vector has zero length.

Common mistakes

  • Forgetting the absolute value, which gives a signed distance.
  • Using a line written as y = mx + c without first moving every term to one side.
  • Dividing by A + B instead of √(A² + B²).

Statistics and uncertainty

These are exact algebraic results from the coordinates, so the uncertainty comes from the inputs. Near-parallel lines and nearly collinear points are the cases where small input errors give large changes in angles or areas.

Where it is used

  • Clearances, offsets and angles between members in drawings, CAD and surveying.
  • Areas of plots, plates and polygon pieces from corner coordinates.

Maths you need

  • Gradient: rise over run of a line
  • Vector: direction and length written as (x, y)
  • Dot product: the sum of products of components

Related formulas

Practise this formula