The distance from a point to a line is the shortest gap, measured perpendicular to the line1. You may join the point to any point of the line you like, but the perpendicular segment is the shortest: any slanted segment is the hypotenuse of a right triangle having the perpendicular as a leg, and a hypotenuse is longer than either leg. Here we find the distance from the origin to the line .
The distance from a point to a line is the following.
| Part | Value here |
|---|---|
| Numerator | |
| Denominator | |
| Distance |
The numerator is the absolute value of what you get by dropping the coordinates of the point into the left-hand side of the line's equation; if the point lies on the line that value is , and so is the distance. The denominator is the length of the vector , which points perpendicular to the line, and dividing by it converts the value of the expression into an actual length.
The perpendicular dropped from to the line is . Substituting into gives , so the foot is . The length from the origin to is , matching the distance from the formula.
This formula is exactly what lies behind comparing the distance from a center to a line with the radius.
| Distance versus radius | The line and the circle |
|---|---|
| cut at two points | |
| tangent | |
| do not meet |
The circle has center and radius , and the distance is , so this line is tangent to it.
Without the absolute value, the sign of tells you which side of the line the point is on. Separating two sides by that sign is the idea behind the machine-learning methods that split data with a line, or a hyperplane2.
The large dots on the graph are the point and the foot of the perpendicular; the length of the segment joining them is the distance we wanted.