Point to Line Distance Calculator
Geometry
- Line value at the point: 3.00 x 5.00 + 4.00 x 5.00 + -10.00 = 25.00.
- Normal length: sqrt(3.00^2 + 4.00^2) = 5.00, so distance = |25.00| / 5.00 = 5.00.
- Foot of the perpendicular: (2.00, 1.00) is the closest point of the line to (5.00, 5.00).
- Point-to-line distance result: 5.00 units, with the line passing 2.00 units from the origin.
The shortest distance from a point to a line is the perpendicular one, and analytic geometry prices it in one line of arithmetic: substitute the point into the line's left-hand side, take the absolute value, and divide by the length of the normal vector, sqrt(a^2 + b^2). This calculator returns that distance together with the foot of the perpendicular - the actual closest point on the line - and the line's own distance from the origin, the three numbers most geometry, graphics and robotics problems need together.
The foot matters as much as the distance. It is the projection used to reflect points across lines, to find the closest approach of a path to a hazard, to measure regression residuals geometrically, and to locate the tangent point in optimisation. A distance without its foot is a magnitude looking for its location.
This is one of those formulas that quietly underlies half of computational geometry: point-to-segment clamping starts here, distance fields are built from it, and the support vector machine's margin is this computation wearing a suit. The page returns the full trio - distance, foot, origin distance - because in practice the three are consumed together, and computing them from one substitution is cheaper than rediscovering each in a separate tool.
Worked examples
3-4-5 line and the point (5, 5)
(3 · 4 · -10 · 5 · 5)
| Distance from point to line | 5.00 |
| Foot of perpendicular, x | 2.00 |
| Foot of perpendicular, y | 1.00 |
| Line distance from origin | 2.00 |
5-12-13 line and the point (4, 1)
(5 · -12 · 26 · 4 · 1)
| Distance from point to line | 2.62 |
| Foot of perpendicular, x | 2.99 |
| Foot of perpendicular, y | 3.41 |
| Line distance from origin | 2.00 |
Diagonal line x - y + 3 = 0, point (0, 5)
(1 · -1 · 3 · 0 · 5)
| Distance from point to line | 1.41 |
| Foot of perpendicular, x | 1.00 |
| Foot of perpendicular, y | 4.00 |
| Line distance from origin | 2.12 |
The normal-vector formula
The vector (a, b) is perpendicular to the line ax + by + c = 0 - that is what the coefficients mean. Moving from any point on the line toward the query point, the component along this normal is exactly the line expression evaluated at the point, and dividing by the normal's length converts that algebraic value into a true geometric distance. The sign before absolutising even tells you which half-plane the point lives in.
The foot follows from the same idea: start at the point and travel along the normal by the signed distance, scaled by the normal vector over its squared length. The result lies on the line by construction - a built-in check, since substituting the foot back into the line equation must give zero.
The foot computation has a verification built into it that is worth using: substitute the foot's coordinates back into the line expression and the result must be zero, up to rounding. The examples pass this audit - (2.00, 1.00) satisfies 3x + 4y - 10 = 0 exactly, and the others satisfy theirs to the printed precision. When hand-checking a result from any source, this ten-second test catches transposed coefficients and sign slips, the two errors this formula actually suffers from in practice.
The formula's economy hides a small piece of structure worth seeing once: the line value a x0 + b y0 + c is the signed distance already, measured in units of the normal's length, which is why the division by sqrt(a^2 + b^2) is a unit conversion rather than part of the geometry. Normalise the line - divide a, b and c by that length - and the substitution itself returns distances and the constant returns the origin distance, a trick every computational geometer uses to make line coefficients directly readable. The calculator performs the normalisation internally on every evaluation.
- Distance: |a x0 + b y0 + c| / sqrt(a^2 + b^2)
- Foot: point minus normal x (line value) / (a^2 + b^2)
- Line's origin distance: |c| / sqrt(a^2 + b^2)
- The sign of the line value identifies the half-plane
Worked examples
Two of the examples ride on Pythagorean normals - 3-4-5 and 5-12-13 - where every number can be checked by mental arithmetic; the third removes the training wheels with a root-two normal and a negative line value.
The line 3x + 4y - 10 = 0 and the point (5, 5) return 5.00, with Foot of perpendicular, x 2.00, Foot of perpendicular, y 1.00, Line distance from origin 2.00. A 3-4-5 normal makes the arithmetic exact - the kind of example textbooks are built from.
The line 5x - 12y + 26 = 0 and the point (4, 1) return 2.62, with Foot of perpendicular, x 2.99, Foot of perpendicular, y 3.41, Line distance from origin 2.00. A 5-12-13 normal this time, and a foot that lands at fractional coordinates, as real problems usually do.
The line x - y + 3 = 0 and the point (0, 5) return 1.41, with Foot of perpendicular, x 1.00, Foot of perpendicular, y 4.00, Line distance from origin 2.12. A diagonal line at 45 degrees, where the distance is the line value over root two.
The origin distances repay a look: 2.00, 2.00 and 2.12. The first two lines, so different in slope and position, pass at the same distance from the origin - a reminder that a line is located by its normal direction and its origin distance together, and neither alone describes it.
Signed distance and half-planes
Drop the absolute value and the formula becomes the signed distance, one of the hardest-working functions in computational geometry. Its sign partitions the plane into the line's two half-planes; its magnitude drives collision margins, support-vector-machine geometry - where the margin is literally this distance computed for the nearest training points - and the level sets used in graphics shaders. The origin distance is the same formula at (0, 0), reducing to |c| over the normal length.
The examples quietly demonstrate the half-plane reading: the second line's value at its point is +34, the third's is -2, so those points sit on opposite sides of their respective lines. When a problem asks not just 'how far' but 'which side, and where exactly is the closest point', the trio this page returns - distance, foot, origin distance - is the complete answer.
In higher dimensions the same idea becomes the distance from a point to a plane, with the normal length sqrt(a^2 + b^2 + c^2) - the formula's family resemblance is exact, and code written for the line case generalises by adding a term. Graphics programmers meet the 2D version as the signed distance function of a line segment's supporting line, the primitive from which rounded shapes, text rendering and shader art are assembled. A formula learned once, in this elementary setting, is repaid across an entire field.
Applications multiply once the signed version is in hand: the distance from a GPS fix to a route line, the clearance of a robot's path from a wall, the residual of a point from a fitted trend in total-least-squares regression - where, unlike ordinary regression, this perpendicular distance is precisely the quantity minimised. That last use closes a loop: the formula that measures a point's offence against a line is also the objective function for fitting the line that offends the points least, in the geometric sense.
| Line | Point | Distance | Foot |
|---|---|---|---|
| 3x + 4y - 10 = 0 | (5, 5) | 5.00 | (2.00, 1.00) |
| 5x - 12y + 26 = 0 | (4, 1) | 2.62 | (2.99, 3.41) |
| x - y + 3 = 0 | (0, 5) | 1.41 | (1.00, 4.00) |
Entering lines in other forms
Lines given as y = mx + b rearrange to mx - y + b = 0, so a = m, b = -1, c = b. A line through two points is best converted through the two-point form into the same coefficients. Vertical lines are no obstacle in this form - x = 4 is simply a = 1, b = 0, c = -4 - which is one reason the general form is the right input. Keep the coefficients in any consistent unit; the distance inherits the coordinate units.
Precision note: when the point lies almost on the line, the line value is a small difference of larger numbers and floating-point cancellation can cost digits. The foot remains accurate - it is computed from a ratio - but for near-zero distances in critical code, formulations based on the cross product of edge vectors are the stabler route. For the classroom, graphics and geometry uses this page serves, the direct formula's accuracy is more than sufficient, as the worked examples' exact audits show.
FAQs
How far is (5, 5) from 3x + 4y - 10 = 0?
5.00. The line value at the point is 25 and the normal length is 5, so the distance is 25 / 5.
Where is the foot for that example?
At (2.00, 1.00) - the point of the line closest to (5, 5), which satisfies the line equation exactly.
What distance does (4, 1) have to 5x - 12y + 26 = 0?
2.62, with the foot at (2.99, 3.41). The normal here is a 5-12-13 vector of length 13.
How far is that line from the origin?
2.00 - |c| over the normal length, 26 / 13.
And the diagonal line x - y + 3 = 0 from (0, 5)?
1.41 away, with the foot at (1.00, 4.00) and the line passing 2.12 from the origin.
Why do two examples share an origin distance of 2.00?
Coincidence of the chosen constants: 10/5 and 26/13 both equal 2.00. The third line's origin distance is 2.12.