HuntsvilleEngineers mark
HE Reference Shelf — huntsvilleengineers.com
The Reference Shelf · Geometry & Mechanics

Distance formulas

The family of formulas that turn "how far apart are these two things" into a number you can compare against a tolerance — point to point, point to line, point to plane, line to line.

Also known as: point-to-line distance · point-to-plane distance

The formula (the core equation(s), each with a one-line reading of what it says)

Point to point:   d = √( (x₂−x₁)² + (y₂−y₁)² + (z₂−z₁)² )

Reads: the Pythagorean theorem in coordinates — square each axis gap, add, take the root. Drop the z term for 2D.

Point to line (2D):   d = |a·x₀ + b·y₀ + c| / √(a² + b²)

Reads: plug the point into the line equation ax + by + c = 0; the leftover, divided by the length of the normal vector (a, b), is the perpendicular distance.

Point to plane:   d = |a·x₀ + b·y₀ + c·z₀ + d₀| / √(a² + b² + c²)

Reads: same move one dimension up — the residual of the plane equation at the point, normalized by the plane's normal.

Point to line (3D):   d = |(P − A) × u| / |u|

Reads: for a line through point A with direction u, the cross product measures the sideways component of the offset from A to P — the part perpendicular to the line.

Line to line (skew, 3D):   d = |(B − A) · (u × v)| / |u × v|

Reads: the gap between two non-intersecting lines is the offset between them projected onto the one direction perpendicular to both.

Where you meet it (2-4 concrete engineering situations, specific: bench, test stand, review board)

The CMM bench, checking true position. A hole lands 0.05 mm off in x and 0.12 mm off in y from its basic location. Radial error is √(0.05² + 0.12²) = 0.13 mm, and true position is twice that: 0.26 mm diametral. If the drawing says position within 0.25, the part is out — and the argument at the bench about whether "it's only 0.13 off" comes down to whether everyone in the room knows the formula doubles.

The clearance review before CDR. A cable harness runs past a hydraulic line, both modeled as straight segments over the span that matters. Minimum separation is a skew-line distance: |(B−A)·(u×v)| / |u×v|. The CAD tool computes it, but when the review board asks "what's the clearance after worst-case tolerance stack and thermal growth," someone has to run the number by hand with the deflected geometry — and the perpendicular distance is the only one that counts. Slant measurements off a screenshot always read long.

Flatness and residuals on the test stand. Fit a plane to a few hundred probe points on a mounting pad, then evaluate every point's signed point-to-plane distance. Flatness is max minus min of those residuals. Every least-squares fit report you have ever signed is a stack of point-to-line or point-to-plane distances wearing a statistics costume.

RF line-of-sight siting. Whether an obstruction intrudes into a link's Fresnel zone starts with the perpendicular distance from the obstacle to the direct ray — point-to-line in 3D, before any of the RF math even wakes up.

How it works (the real substance — behavior, gotchas, limits of validity, the mistake people make)

All five formulas are one idea: decompose the offset vector into a component along the reference object and a component perpendicular to it, and keep only the perpendicular part. The √(a² + b²) and |u × v| denominators are doing the same job — normalizing so the answer comes out in length units instead of in whatever arbitrary scale the line or plane equation happened to be written in.

That denominator is the classic mistake. The plane 2x + 3y + 6z − 12 = 0 and the plane 4x + 6y + 12z − 24 = 0 are the same plane, but the raw residual at point (1, 1, 1) is −1 for the first and −2 for the second. Divide by the normal's length — √(4+9+36) = 7 — and both give the true distance, 1/7 ≈ 0.143. Skip the division and your "distance" depends on how the equation was scaled, which is meaningless. Hesse's normal form exists precisely to bake that division in once, so the residual is the distance.

The absolute value bars are worth removing on purpose. The signed residual tells you which side of the line or plane the point sits on — positive on the normal side, negative opposite. Clearance checks, interference detection, and flatness evaluation all need the sign; a point 0.1 mm inside the keep-out plane and a point 0.1 mm outside it have the same unsigned distance and very different consequences.

Second gotcha: perpendicular distance is not vertical distance. Ordinary least squares minimizes vertical residuals (y_i − ŷ_i); the geometric distance from the point to the fitted line is shorter by a factor of 1/√(1 + m²) for slope m. On a shallow calibration curve the two are nearly identical. On a steep one they diverge badly — at slope 2 the perpendicular residual is 45% of the vertical one — and a fit that looks fine by vertical residuals can hide real geometric scatter. When both variables carry measurement error, orthogonal (total least squares) fitting minimizes the true perpendicular distances instead. Know which one your software is doing before you quote a residual to a customer.

Limits of validity: the formulas assume straight lines, flat planes, and a Euclidean space with consistent units on every axis. Mix millimeters on x with inches on y and the square root cheerfully returns garbage. Plot pressure against time and the "distance" from a point to a trend line has no physical meaning at all until you decide how a second trades off against a psi — which is why orthogonal fitting on mixed-unit data requires explicit scaling choices. And latitude-longitude pairs are not Cartesian coordinates; running the flat-earth formula on them fails at any range where the Earth's curvature matters. One more boundary that bites in exactly the CDR situation above: the point-to-line (3D) and skew-line formulas are distances between infinite lines. For finite segments — a harness run, a hydraulic line — you must check that the closest-approach points actually land within both spans; if either foot falls off the end of its segment, the true minimum is endpoint-to-segment or endpoint-to-endpoint, and the skew-line formula reads short. That error is conservative for a clearance check, but it will not match the segment-based minimum your CAD tool reports, and the discrepancy will surface at the review board.

Numerically, watch two edges: the skew-line formula divides by |u × v|, which goes to zero as the lines approach parallel — near-parallel geometry needs the point-to-line formula against either line instead. And subtracting nearly equal large coordinates (global CAD coordinates in the hundreds of meters, deviations in microns) burns floating-point precision; translate the problem to a local origin first.

History (who derived it and when, told as a short story with inline [n] citations)

The point-to-point formula is the oldest mathematics on this site. The right-triangle relation it encodes was proved as Proposition 47 of Book I of Euclid's Elements around 300 BC [1][2], and evidence of the underlying number relationships is older still. What Euclid lacked was coordinates — for him distance was a line segment, not a number computed from other numbers.

Coordinates arrived in the 1630s, twice at once. Pierre de Fermat circulated his Ad locos planos et solidos isagoge in manuscript around 1636, and René Descartes published La Géométrie as an appendix to the Discours de la méthode in 1637 [3][4]. Between them they built the machine that turns geometry into algebra: once a point is a pair of numbers, Euclid's proposition becomes a formula, and every distance question becomes arithmetic. Neither man wrote the modern distance formula as a display equation — the notation settled later — but the formula is nothing more than I.47 passed through their coordinate system.

The point-to-line and point-to-plane formulas got their standard form from Ludwig Otto Hesse (1811–1874), a Königsberg-born geometer who taught Kirchhoff and Clebsch and finished his career at the new Munich Polytechnic [5][6]. His textbooks on analytic geometry — space in 1861, the plane in 1865 — popularized writing the line and plane equations with a unit normal, so that evaluating the equation at any point directly yields the signed distance [5]. That convention is still called the Hesse normal form [6][7], and it is the reason the √(a² + b²) denominator works.

The last piece is the one engineers use most and credit least. In 1901 Karl Pearson published "On lines and planes of closest fit to systems of points in space" in the Philosophical Magazine, posing the fitting problem geometrically: find the line or plane minimizing the sum of squared perpendicular distances to the data [8][9]. That single paper is the ancestor of orthogonal regression and principal component analysis — the moment point-to-plane distance stopped being a geometry exercise and became the residual in every fit report since.

Related tools (bullet list of HE calculator slugs that use or neighbor this topic, as /tools/ links)

Sources

  1. https://mathcs.clarku.edu/~djoyce/java/elements/bookI/propI47.html
  2. https://en.wikipedia.org/wiki/Pythagorean_theorem
  3. https://www.britannica.com/science/mathematics/Analytic-geometry
  4. https://en.wikipedia.org/wiki/Analytic_geometry
  5. https://mathshistory.st-andrews.ac.uk/Biographies/Hesse/
  6. https://en.wikipedia.org/wiki/Ludwig_Otto_Hesse
  7. https://en.wikipedia.org/wiki/Hesse_normal_form
  8. https://www.tandfonline.com/doi/abs/10.1080/14786440109462720
  9. https://pca.narod.ru/pearson1901.pdf

Written by HE in our own words from the cited sources — engineering judgment included, your stamp still required. All entries →

★ The Reference Shelf

Reading is free. The shelf is for cardholders.

Your library card is an email address: pin it to your shelf, print the card, take the FE/PE quick-reference pack, read the Huntsville history. The shelf remembers what you reach for.

Already on the list? Enter with your subscribed email →