One robust formula
d = |Ax₀ + By₀ + C| / √(A² + B²) handles every non-degenerate 2D line—no slopes, no special cases for verticals.
Note: vertical lines are not of the form y=mx+b. Use Standard or Two points for those.
Formula (standard form): d = |A x₀ + B y₀ + C| / √(A² + B²). Tip: Press Enter in any field to calculate.
The blue line is infinite. The red segment shows the perpendicular distance from your point to the line.
For a line given by A x + B y + C = 0 and a point P=(x₀,y₀), the perpendicular
distance is
d = |A x₀ + B y₀ + C| / √(A² + B²).
If you prefer y = m x + b, the equivalent standard form is -m x + 1·y - b = 0
(so A=-m, B=1, C=-b). For a line through points
P₁=(x₁,y₁) and P₂=(x₂,y₂), one valid standard form is:
A = y₁ - y₂, B = x₂ - x₁, C = x₁ y₂ - x₂ y₁.
Ax+By+C=0 internally.d = |Ax₀ + By₀ + C| / √(A² + B²) handles every non-degenerate 2D line—no slopes, no special cases for verticals.
Distance equals 2 × area ÷ base. Build a triangle from your point and any two points on the line; the height is the perpendicular distance.
Drop the absolute value and you get a signed distance field—core to smooth text rendering, vector fills, and GPU-friendly shapes.
Among all paths from a point to a line, the perpendicular wins. Any tilted hop is longer—a tiny optimization principle baked into geometry.
In linear regression, the vertical residuals are distances to a fitted line—but not perpendicular ones. Orthogonal regression swaps in true perpendiculars.
The distance is zero and the perpendicular foot equals the point.
Standard form with A=B=0, or Two Points with identical points. For vertical lines, use Standard or Two Points.
Calculations use full floating-point precision and are displayed rounded to 6 decimals by default.
The perpendicular (shortest) distance from a point to a line is a staple result in analytic
geometry, computer graphics, robotics, surveying, GIS, and more. Given a point
P=(x₀, y₀) and a line, we measure how far you’d travel along a direction that is
orthogonal to the line to reach it. This calculator supports three common line forms and converts
everything into the robust standard form A x + B y + C = 0.
If the line is A x + B y + C = 0, the perpendicular distance is:
d = |A x₀ + B y₀ + C| / √(A² + B²).
This expression is scale-invariant: multiplying (A, B, C) by any nonzero constant does not change
the result, because both numerator and denominator scale together.
y = m x + b ⇒
rewrite as -m x + 1·y - b = 0, so
A = -m, B = 1, C = -b. Then apply the core formula.
A compact version is d = |m x₀ - y₀ + b| / √(m² + 1).
P₁=(x₁, y₁), P₂=(x₂, y₂) (distinct): a
convenient determinant form is
d = |(x₂ - x₁)(y₁ - y₀) - (x₁ - x₀)(y₂ - y₁)| / √((x₂ - x₁)² + (y₂ - y₁)²).
Often you also want where the perpendicular meets the line. For A x + B y + C = 0,
let k = (A x₀ + B y₀ + C) / (A² + B²). Then the foot F=(x_f, y_f) is
x_f = x₀ - A k, y_f = y₀ - B k. If the distance is zero, P already lies
on the line and F = P.
This tool reports the unsigned distance. If you need a signed distance, drop the absolute value:
d_s = (A x₀ + B y₀ + C) / √(A² + B²). The sign tells you on which side of the oriented line the
point falls (based on the direction of the normal vector (A, B)).
Point P=(2, -1), line 2x − y − 3 = 0. Then
d = |2·2 + (−1)·(−1) − 3| / √(2² + (−1)²) = |4 + 1 − 3| / √5 = 2 / √5 ≈ 0.894427.
For the foot: k = (2·2 + (−1)·(−1) − 3)/(2² + (−1)²) = 2/5, so
x_f = 2 − 2·(2/5) = 1.2, y_f = −1 − (−1)·(2/5) = −0.6.
Ax+By+C=0 or the two-point form; y=mx+b cannot represent verticals.(A,B,C); the formula handles scaling automatically.Applications include measuring shortest offsets to roads or edges (GIS), snapping objects to guides (graphics/CAD), collision & steering behaviors (games/robotics), residuals in linear regression, and more.