🧮
🧮 Math & statistics

Distance from a Point to a Line

Results update as you type.

Your numbers

Understanding the point-to-line distance calculator — concept and principle

The distance from a point to a line is the length of the shortest segment between them, which always meets the line at a right angle. This calculator takes a line written as ax + by + c = 0 and a point (x₀, y₀), and returns that distance together with the foot of the perpendicular, the point on the line closest to the given point. It is used in analytic geometry, in clearance checks on drawings, in computer graphics and collision detection, and in least-squares fitting.

Point (5, 6) and the line 3x + 4y − 10 = 0 with the perpendicular between themThe house at (5, 6) is 29 away in the line equation 3·5 + 4·6 − 10; dividing by √(3² + 4²) = 5 gives the true distance 5.8. The shortest path meets the road at a right angle at (1.52, 1.36); any slanted path is longer.Shortest walk from a house to the road02460246(5, 6)5.8road3x + 4y − 10 = 0plug in (5, 6)|15 + 24 − 10| = 29√(3² + 4²)= 529 ÷ 5distance 5.8gold dot = foot(1.52, 1.36)
Plug the point into the line, take the absolute value, divide by √(a² + b²).

How it is calculated

a and b cannot both be zero. If your line is in the form y = mx + k, rewrite it as mx − y + k = 0, so a = m, b = −1, c = k.

The principle

The vector (a, b) is perpendicular (normal) to the line ax + by + c = 0. The shortest route from the point to the line therefore runs along this normal direction. Substituting the point into the left side gives the value ax₀ + by₀ + c, which is zero for points on the line and grows in proportion to how far the point lies from it, measured in steps of the normal's length √(a² + b²). Dividing by that length converts the value into an actual distance; the absolute value removes the sign, which only tells you on which side of the line the point is. To find the foot, start at the point and move back along the normal by exactly that amount, which is what the factor t does.

Worked example

  1. Inputs: line 3x + 4y − 10 = 0, point (5, 6).
  2. Substitute: 3 × 5 + 4 × 6 − 10 = 15 + 24 − 10 = 29.
  3. Normal length: √(3² + 4²) = 5.
  4. Distance: |29| ÷ 5 = 5.8.
  5. Foot: t = 29 ÷ 25 = 1.16, so (5 − 3 × 1.16, 6 − 4 × 1.16) = (1.52, 1.36). Check: 3 × 1.52 + 4 × 1.36 = 10, so it lies on the line.
How Distance changes with Point y₀How Distance changes with Point y₀246810121.534.567.5912Example: 5.8Point y₀
Each point is the calculator re-run with only “Point y₀” changed; the gold point is the default example. Change the inputs above and this chart follows your numbers.
Point y₀Distance
1.52.2
33.4
4.54.6
65.8
7.57
98.2
1210.6

How to read the result

The distance is always zero or positive; zero means the point is on the line. The sign of ax₀ + by₀ + c (here positive) shows which side of the line the point is on, which is useful for testing whether two points are on the same side. Multiplying the whole equation by a constant, such as 6x + 8y − 20 = 0, does not change the distance, because numerator and denominator scale together.

Common mistakes

Keep in mind: The formula is for an infinite straight line in a plane. For a line segment, the closest point may be an endpoint, and in 3D or on a curved surface a different method is needed.

Frequently asked questions

How do I find the distance between two parallel lines?

For ax + by + c₁ = 0 and ax + by + c₂ = 0, d = |c₁ − c₂| ÷ √(a² + b²).

How do I get the reflection of the point across the line?

Go twice as far along the normal: (x₀ − 2a·t, y₀ − 2b·t). For the example, (−1.96, −3.28).

Does the formula work for y = mx + k?

Yes, after rewriting: d = |mx₀ − y₀ + k| ÷ √(m² + 1).

Sources: J. Stewart, L. Redlin and S. Watson, Precalculus: Mathematics for Calculus, Cengage · D. Zwillinger (ed.), CRC Standard Mathematical Tables and Formulae, CRC Press, analytic geometry of the plane

Checked 8 Nov 2026. Standard formulas, computed in your browser with double-precision numbers.

🧮 All math & statistics tools →🌍 Calculators by country →