The distance between a point $$P$$ and a straight line $$r$$ is the minimum of the distances between $$P$$ and any point on the straight line.
We can distinguish two cases:
- If $$P$$ belongs to the straight line $$r$$, $$d (P, r) = 0$$.
- If $$P$$ does not belong to the straight line $$r$$, $$d (P, r)$$, it is the module of the vector $$\overrightarrow{QP}$$, where $$Q$$ is the intersection point between the straight line $$r$$ and the perpendicular to $$r$$ that crosses $$P$$.
Let $$Ax + By + C = 0$$ be the general equation of the straight line $$r$$, and $$P =(p_1,p_2)$$ the given point and $$A =(a_1,a_2)$$ any point of the straight line.
If we take a perpendicular vector to $$r$$, for example $$\overrightarrow{n} = (A, B)$$ for the properties of the scalar product in the vectors projection we have: $$$\displaystyle d(P,r)=\frac{|\overrightarrow{AP} \cdot \overrightarrow{n}|}{\overrightarrow{n}}=\frac{|A\cdot p_1+B\cdot p_2-(A\cdot a_1+B\cdot a_2)|}{\sqrt{A^2+B^2}}$$$ But since $$A = (a_1,a_2)$$ is a point of the straight line $$r$$, it verifies its equation: $$$A\cdot a_1+B\cdot a_2+C=0 \leftarrow A\cdot a_1+B\cdot a_2=C$$$ Therefore we obtain the following formula: $$$d(P,r)=\displaystyle \frac{|A\cdot p_1+B\cdot p_2+C|}{\sqrt{A^2+B^2}}$$$
Let $$P = (-1, 2)$$ be a point and $$r: 4x - 3y + 1 = 0$$ a straight line. Calculate the distance between the point and the straight line.
Applying the previous formula we have: $$$\displaystyle d (P, r) =\frac{A\cdot p_1+B\cdot p_2+C}{\sqrt{A^2+B^2}}=\frac{|4\cdot (-1)+(-3)\cdot 2+1|}{\sqrt{4^2+(-3)^2}}=\frac{9}{5} $$$