InfyCalculator
➗

Distance from a Point to a Line Calculator

Find the shortest distance from a point (x₀, y₀) to the line Ax + By + C = 0, with the exact value, the foot of the perpendicular and whether the point lies on the line.

A (coefficient of x)
B (coefficient of y)
C (constant)
Point x₀
Point y₀
Loading calculator…

How it works

d = |A·x₀ + B·y₀ + C| / √(A² + B²) · foot of the perpendicular: (x₀ − A·k, y₀ − B·k), k = (A·x₀ + B·y₀ + C)/(A² + B²)

The shortest path from a point to a line is the perpendicular segment. Plugging the point into Ax + By + C gives a value proportional to its signed distance, and dividing by the length of the normal vector (A, B) turns it into the actual distance. If the line is in slope-intercept form y = mx + b, rewrite it as mx − y + b = 0, so A = m, B = −1 and C = b.

Worked example

For the line 3x + 4y − 10 = 0 and the point (5, 6): 3·5 + 4·6 − 10 = 29 and √(3² + 4²) = 5, so d = 29/5 = 5.8. The closest point on the line is (5 − 3·29/25, 6 − 4·29/25) = (1.52, 1.36).

Sources: Distance from a point to a line — Wikipedia · Point-Line Distance — Wolfram MathWorld

Frequently asked questions

How do I use y = mx + b with this formula?

Move everything to one side: mx − y + b = 0. Then A = m, B = −1, C = b. For y = 2x + 1 enter A = 2, B = −1, C = 1.

What if the line is vertical or horizontal?

A vertical line x = k is 1·x + 0·y − k = 0, so the distance is |x₀ − k|; a horizontal line y = k gives |y₀ − k|. The general formula handles both.

What does a distance of 0 mean?

The point satisfies the equation, so it lies on the line.

How do I find the distance between two parallel lines?

Write both as Ax + By + C₁ = 0 and Ax + By + C₂ = 0 with the same A and B; the distance is |C₁ − C₂| / √(A² + B²). Or pick any point on one line and use this calculator with the other.

Related calculators

This calculator is for educational purposes. Double-check important results before acting on them.