# Explaining formulas for $A$, $B$, $C$ in the equation $Ax+By+C$ of the line through two given points

In a computer program, I can make a line equation $$Ax + By + C$$ from two points like:

\begin{align} A &= y_2-y_1 \\ B &= x_1-x_2 \\ C &= A\cdot x_1+B\cdot y_1 \end{align}

Source on TopCoder.com

I do not understand how $$A$$, $$B$$, $$C$$ values arise from the points.

Thank you.

If the line goes through the points $(x_1, y_1)$ and $(x_2, y_2)$, then a point $(x, y)$ is on the line if and only if $\frac{x-x_1}{y-y_1} =\frac{x_2-x_1}{y_2-y_1}$ or $x(y_2-y_1)-x_1(y_2-y_1) =y(x_2-x_1)-y_1(x_2-x_1)$ or $x(y_2-y_1)-y(x_2-x_1) =x_1(y_2-y_1)-y_1(x_2-x_1)$ which is your equation.
• Some care must be taken since the line may be horizontal, in which case $\frac{x_2-x_1}{y_2-y_1}$ is undefined. Commented Apr 28, 2015 at 21:56
• This is the two-point form of a straight line. It says that, if the slope of a line is $r$, then, for any two points $(x_1, y_1)$ and $(x_2, y_2)$ on the line, $(y_2-y_1)/(x_2-x_1) = r$. Commented Apr 28, 2015 at 22:35