As most of you know, the distance between a point $p$ coordinates $(x_p, y_p)$ and a line $L$, equation $a*x+b*y+c = 0$, can be written as:
$$\frac{a*x_p+b*y_p+c}{\sqrt{(a^2+b^2)}}$$
There are different ways to derive this formula, some of them shown in this post.
There is, however, one interpretation I'm missing:
Imagine the formula of a straight line, written as:
$$F(x,y) = a*x+b*y+c = 0$$
Then the function $F$ is simply defined as the function, so that if $F(x_q,y_q)=0$, then the point $q$ is located on the line.
Next to that, the distance between a point and the line, described by $F$, can be written as:
$$D(p,F) = \frac{F(x_p, y_p)}{N(F)}$$
where $N(F)$ is some norming factor, based on the function $F$.
This automatically raises some questions :
- What's the interpretation of the function $F$, more exactly what means $F(q)$ for $q$ not being on the line?
- Where's the norming factor coming from?
Can anybody give me a hint on that interpretation or is it a mere coincidence?
Best Answer
Now, the reason why this vector appears is because when you calculate the distance using this formula $F$, what you are doing is:
Let $P$ be the point with coordinates $(x_0, y_0)$ and let the given line have equation $ax + by + c = 0$. Also, let $Q = (x_1, y_1)$ be any point on this line and $\vec n$ the vector $(a, b)$ starting at point Q.
The vector n is perpendicular to the line, and the distance d from point P to the line is equal to the length of the orthogonal projection of $\vec {QP}$ on $\vec n$. The length of this projection is given by: $$d= \frac{|\vec {QP} \cdot \vec n|}{||\vec n||}$$
Now $\vec {QP} =(x_0-x_1, y_0 - y_1)$ so $\vec {QP} \cdot \vec n = a(x_0-x_1) + b(y_0 - y_1)$ and $||\vec n||=\sqrt{a+b}$