Distance from a point to a line
The distance from a point to a line is the length of the “shortest” line segment from the point to the given line.
The problem
We have a line p and a point A that does not lie on it. We want to know the distance from the point A to the line p. As an example we take the line given by the general form p: −x + 2y − 12 = 0 and the point A(6, 4):
The distance from the point to the line is then the length of the line segment AB, where the line AB is perpendicular to the line p and the point B lies on the line p. We denote the line AB by q.
Using the formula
If you do not want to derive anything or do any “complicated” working, you can simply remember a formula. For a point A(a1, a2) and a line p given by the general form p: ax + by + c = 0, the distance from A to p is
We can apply the formula to the example above. We substitute:
Finding the coordinates of the foot of the perpendicular
Alternatively, we can try to work out the coordinates of the point B. We can then find the length of the line segment AB easily, using the magnitude of a vector or Pythagoras’ theorem. The equation of the line q can help us here. From the general form of the line p we can read off the normal vector of p straight away: it is
One such perpendicular vector is
We find the coefficient c by substituting the coordinates of a point that certainly lies on the line for x and y. In our case this is the point A(6, 4). We get:
The complete general form of the line q is:
Now we want to find the point of intersection of the two lines. We find it by putting the equations of both lines into a system of equations and solving it:
We multiply the first equation by 2 and leave the second unchanged:
We add the two equations:
The y-coordinate of the point B is y = 8. We substitute this value into one of the equations, for example −x + 2y − 12 = 0:
The point B has coordinates B(4, 8). Now we know the coordinates of both points, and finding the length of the line segment is easy. We can form the vector
The magnitude of the vector (−2, 4) is then:
Chapters: Distance from a point to a line, Distance from a point to a plane, Distance between two parallel lines