Why $\frac{|Ap+Bq+C|}{\sqrt{A^2+B^2}}$ is the shortest distance from a point$(p,q)$ to a line equation $Ax+By+C=0$? I want to show the statement
"Let $(h,k)$ be a point on a line  $Ax+By+C=0$  prove that $\sqrt{(h-p)^2+(k-q)^2}$ $\geq$ $\frac{|Ap+Bq+C|}{\sqrt{A^2+B^2}}$" is true.
I do try to prove it with contradiction.
Proof Suppose $(h,k)$ is a point on the line $Ax+By+C=0$
and $\sqrt{(h-p)^2+(k-q)^2}$ $<$ $\frac{|Ap+Bq+C|}{\sqrt{A^2+B^2}}$
Consider In coordinate system, Draw a right triangle from point$(a,b)$ and any two points on the line

And now I stuck with this step how to show it contradicts.
Could you help me please?
Do you have any ideas to prove it?
Thank you very much.
 A: The line through the origin orthogonal to $AX+BY+C=0$ is $-BX+AY=0$ and their intersection is given by
$$A\frac A B Y+BY+C=0 \iff (A^2+B^2)Y=-BC \\\iff Y_0= -\frac{BC}{A^2+B^2} \quad X_0=-\frac{AC}{A^2+B^2}$$
therefore
$$d_0=\sqrt{X_0^2+Y_0^2}=\frac{|C|}{\sqrt{A^2+B^2}}$$
Now, with reference to a point $P=(x_P,y_P)$ in the coordinates $x$ and $y$, let consider the translation such that $P\equiv O$ in the coordinates $X$ and $Y$

*

*$X=x-x_P$


*$Y=y-y_P$
then we have
$$Ax+By+C=0 \iff AX+BY+(Ax_p+By_p+C)=0$$
and therefore
$$d_P=\frac{|Ax_p+By_p+C|}{\sqrt{A^2+B^2}}$$
since the distance is independent from the reference system.
A: Suppose $(x_{0},y_{0})$ lies on the line i.e. $Ax_{0}+By_{0}+C=0$
$$
\frac{\left|Ax+By+C\right|}{\sqrt{A^{2}+B^{2}}}=\frac{\left|A(x-x_{0})+B(y-y_{0})\right|}{\sqrt{A^{2}+B^{2}}}
$$
The right hand side of the equation is dot product between vectors $A\hat{i}+B\hat{j}$ and $(x-x_{0})\hat{i}+(y-y_{0})\hat{j}$ divided by length of the first vector.
A: Rewriting the line equation as $y=\left(\frac {-A}{B}\right)x-\frac {C}{B}$, we can write the direction vector as ${B \choose -A}$.
Through the point $(x,y)$, if we draw a new line perpendicular to the given line, we will get an intersection point, say $(x_0, y_0)$.
Then we use the dot product of vectors:$\left({x \choose y}-{x_0 \choose y_0}\right)\cdot{B \choose -A}=0$$\Rightarrow B^2(x-x_0)^2=A^2(y-y_0)^2$$\Rightarrow(y-y_0)^2=\frac{B^2}{A^2}(x-x_0)^2.\qquad(1)$
Also, by substituting $y_0=\frac{-Ax_0-C}{B}$ into $B(x-x_0)=A(y-y_0)$ which is from the previous dot product, we can get $x-x_0=\frac{A(Ax+By+C)}{A^2+B^2}.\qquad(2)$
Finally, by substituting $(1)$ and $(2)$ into $\sqrt{(x-x_0)^2+(y-y_0)^2}$ which represents the wanted shortest distance, we would get the desired result.
A: Algebraically:
Notice that
$$Ax+By+C=0\land Aa+Bb+C=0\implies A(x-a)+B(y-b)=0.$$
So with $\tilde x:=x-a,\tilde y:=y-b$ and squaring,
$$\tilde x^2+\tilde y^2\ge\frac{(A\tilde x+B\tilde y)^2}{A^2+B^2},$$
and after simplification this is equivalent to
$$(B\tilde x-A\tilde y)^2\ge0,$$ which is true.
A: Since $Aa+Bb+C=0$, the Cauchy-Schwarz inequality gives
\begin{align}
|Ax+By+C| &= |(Ax+By+C)-(Aa+Bb+C)| \\
&= |A(x-a)+B(x-b)|\\
&\le \sqrt{A^2+B^2}\sqrt{(x-a)^2+(y-b)^2}.
\end{align}
A: The special case $A=0,\,B=1$ is trivial, and other cases reduce to this through a combination of rotation (changing the coordinate system) and scaling (changing how the line is described within a given coordinate system).
