Foot of perpendicular proof. I know there is few answer on Foot of perpendicular, but my doubt is different, so please don't mark this as the duplicate.
My book says:

Foot of the perpendicular from a point $(x_1,y_1)$ on the line $ax+by+c=0$ is $$\dfrac{x-x_1}{a}=\dfrac{y-y_1}{b}=-\dfrac{ax_1+by_1+c}{a^2+b^2}$$

My proof:
Slope of line $\perp$ to $ax+by+c=0$ is $\frac{b}{a}\implies\tan\theta=\frac{b}{a}\implies\begin{cases}\cos\theta &=\pm\frac{a}{\sqrt{a^2+b^2}}\\ \sin\theta &=\frac{b}{\sqrt{a^2+b^2}}\end{cases}$
Let $L$ passes through point $(x_ 1,y_1)$ perpendicular to $ax+by+c=0$.
Let $r$ be the algebraic distance of $(x_ 1,y_1)$ from $ax+by+c=0$ $\implies r=\frac{ax_1+by_1+c}{\sqrt{a^2+b^2}}$.
Now co-ordinate of any point on $L$ distance $r$ from point $(x_1,y_1)$ can be given as:$$\bigg(x_1+r\cos \theta,\ y_1+r\sin\theta\bigg)$$, where $\theta$ is angle $L$ makes with positive direction of $x$-axis.
Substituting the values:$$\bigg(x_1+\frac{ax_1+by_1+c}{\sqrt{a^2+b^2}}\cdot\frac{a}{\sqrt{a^2+b^2}},\ y_1+\frac{ax_1+by_1+c}{\sqrt{a^2+b^2}}\cdot\frac{b}{\sqrt{a^2+b^2}}\bigg)$$ Now I didn't wrote $\pm$ with $\cos$, whose sign can be calculated as of $\tan$.
Now camparing gives :
$x=x_1+\frac{ax_1+by_1+c}{\sqrt{a^2+b^2}}\cdot\frac{a}{\sqrt{a^2+b^2}}$,   $\ \ \ y=y_1+\frac{ax_1+by_1+c}{\sqrt{a^2+b^2}}\cdot\frac{b}{\sqrt{a^2+b^2}}$
Note, I didn't mixed the denominators $\bigg(\sqrt{a^2+b^2}\bigg)$ to $\bigg(a^2+b^2\bigg)$, as I've calculated $\frac{a}{\sqrt{a^2+b^2}}$ from $\tan\theta$ with sign.
When I applied this on some problems gives me the correct answers but is not in the bookish form please help me to do this.
 A: There are many way to find the foot of the perpendicular. The bookish formula is the same as yours! Just a little bit of reordering:
I pick up from where you stopped.
$$x=x_1-\frac{ax_1+by_1+c}{\sqrt{a^2+b^2}}\cdot\frac{a}{\sqrt{a^2+b^2}}$$
$$ y=y_1-\frac{ax_1+by_1+c}{\sqrt{a^2+b^2}}\cdot\frac{b}{\sqrt{a^2+b^2}}$$
I don't see a reason why you can't mix the denominators.
$$x=x_1-(ax_1+by_1+c)\cdot\frac{a}{{a^2+b^2}}$$
$$\frac{x-x_1}a=-\frac{ax_1+by_1+c}{a^2+b^2}$$
Similarly,
$$y=y_1-(ax_1+by_1+c)\cdot\frac{b}{{a^2+b^2}}$$
$$\frac{y-y_1}b=-\frac{ax_1+by_1+c}{a^2+b^2}$$
Or
$$\frac{x-x_1}a=\frac{y-y_1}b=-\frac{ax_1+by_1+c}{a^2+b^2}$$
Note:
The negative sign is due to our assumption that the foot of the perpendicular is below the given point. You probably may have assumed the foot of perpendicular is above the point.
Excuse me if I am wrong somewhere.
A: First the algebraic distance $r$ should be $\dfrac{|ax_1+by_1+c|}{\sqrt{a^2+b^2}}$ depending on the position of $(x_1;y_1)$ for a given system of coordinates.
The correct formula is $$\dfrac{x-x_1}{a}=-\dfrac{ax_1+by_1+c}{a^2+b^2}.$$
To see this take the scalar product to be zero for $(x,-\dfrac{ax}{b}-\frac{c}{b})$ is on the line of direction $\overrightarrow{v}(1;-\frac{a}{b})$:
$$(x_1-x)\times 1+(y_1-(-\dfrac{ax}{b}-\frac{c}{b}))(\dfrac{-a}{b})=0.$$
