If a straight line $ax+by+c=0$ divides the line segment joining the points $A(x_1,y_1)$ and $B(x_2,y_2)$ in the ratio $k:1$, the standard way of finding $k$ is to use the section formula and input the point of intersection in the equation of the straight line. However, my textbook gives the following shortcut but doesn't prove it:
$$\frac{AP}{PB} = k = - \frac{ax_1+by_1+c}{ax_2+by_2+c}$$
If $k>0$, then $P$ divides $AB$ internally else externally.
Can someone please explain to me why this method works?
Suppose I give you a line $L: ax + by + c = 0$ and a point $P(x_1, y_1)$
Then
$$d(P,L) = \frac{ax_1 + by_1 + c}{\sqrt{a^2 + b^2}}$$
Where $d(P,L)$ is the signed perpendicular distance of point P from line L
So essentially, when you take the ratio of $d(P_1, L)$ to $d(P_2, L)$ you get
$$r = \frac{d(P_1, L)}{d(P_2, L)} = -\frac{ax_1 + by_1 + c}{ax_2 + by_2 + c}$$
The negative sign is because the point in the interior will be negative for one of the lines and positive for the other line - hence to maintain the sign convention of internal ratios being positive, the negative sign will appear
Now, if we say that from points $P_1$ and $P_2$, we drop perpendiculars to the line $L$ at $H_1$, $H_2$. Also, let $L$ intersect $P_1P_2$ at $X$
Then, the triangles $P_1H_1X$ and $P_2H_2X$ are similar
Therefore, we have
$$r = \frac{d(P_1, L)}{d(P_2, L)} = \frac{P_1H_1}{P_2H_2} = \frac{P_1X}{P_2X} = k$$