Distance of a point from a line

Kapitoly: Distance of a point from a line, Distance of a point from a plane, Distance of two straight lines

The distance of a point from a line is equal to the magnitude of the "shortest" line segment drawn from that point to that line.

Assignment

We have a line p and a point A, which does not lie on this line. We are interested in the distance of the point A from the line p. For an example, we take the line given by the general equation p: −x + 2y − 12 = 0 and the point A[6,4]:

Point A and line p

The distance of the point from the line is then equal to the magnitude of the line AB, where the line AB is perpendicular to the line p and the point B lies on the line p. We will label the line AB q .

Solution using the formula

If you don't want to derive anything and do any "complicated" calculations, you can simply memorize the formula. For the point A[a1, a2] and the line p given by the general equation p: ax + by + c = 0, the distance of the point A from the line p is equal:

$$ v(A, p) = \frac{|a\cdot a_1 + b \cdot a_2+c|}{\sqrt{a^2+b^2}} $$

We can apply the formula to the previous example. Add:

\begin{eqnarray} v(A, p) &=& \frac{|-1\cdot6+2\cdot4-12|}{\sqrt{(-1)^2+2^2}} &=&\frac{10}{\sqrt{5}}=\frac{10}{\sqrt{5}}\cdot \frac{\sqrt{5}}{\sqrt{5}}\\ &=&\frac{10\cdot\sqrt{5}}{5}=2\cdot\sqrt{5}\\ &\approx&4,4721 \end{eqnarray}

Procedure by calculating the intersection coordinate

Alternatively, we can try to calculate the coordinates of the point B. The distance of the line segment AB will then simply go through the magnitude of the vectors or the Pythagorean theorem. For this we can use the equation of the line q. From the general equation of the line p, we can immediately derive the normal vector of the line p, which is equal to $\vec{\mathbf{n}}=(-1, 2)$. Since the lines p and q are perpendicular, this means that if we take a vector $\vec{\mathbf{m}}$, which will be perpendicular to the vector $\vec{\mathbf{n}}$, then this vector $\vec{\mathbf{m}}$ will be the normal vector of the line q.

Such a perpendicular vector is, for example, the vector $\vec{\mathbf{m}}=(2, 1)$ (we can check this by a scalar product, for example). The line q thus has the general equation

$$ q: 2x+y+c=0 $$

We calculate the coefficient c by substituting after x and y the coordinates of a point that is sure to lie on the line. In our case, this is the point A[6,4]. We get:

\begin{eqnarray} 2x+y+c&=&0\\2\cdot6+4+c&=&0\c&=&-16 \end{eqnarray}

The whole general equation of the line q has the form:

$$ q: 2x+y-16=0 $$

Now we want to find the intersection of the two lines. We find the intersection by putting the equations of the two lines into the system of equations and solving it:

\begin{eqnarray} -x+2y-12&=&0\\ 2x+y-16&=&0 \end{eqnarray}

Multiply the first equation by 2, leave the second equation unchanged:

\begin{eqnarray} -2x+4y-24&=&0\\ 2x+y-16&=&0 \end{eqnarray}

Add the two equations:

\begin{eqnarray} -2x+4y-24+(2x+y-18)&=&0\\4y+y-24-18&=&0\5y&=&40\y&=&8 \end{eqnarray}

yThe -coordinate of the point B is y = 8. This value is plugged into an equation, for example −x + 2y − 12 = 0:

\begin{eqnarray} -x+2y-12&=&0\\\ -x+2\cdot8-12&=&0\\ -x+4&=&0\\ x&=&4 \end{eqnarray}

The point B has the coordinates B[4, 8]. Now we know the coordinates of both points. It is easy to calculate the size of the line segment. We can create a vector $\vec{AB}$ from the line segment AB and calculate the size of this vector.

$$ \vec{AB} = B-A=[4, 8] - [6, 4] = [-2, 4] $$

The size of the vector (−2, 4) is then equal to:

$$ |\vec{AB}|=\sqrt{(-2)^2+4^2}=\sqrt{4+16}=\sqrt{20}=\sqrt{4}\cdot\sqrt{5}=2\cdot\sqrt{5}\approx4{,}4721 $$

References and Resources