# Convert two points to line eq (Ax + By +C = 0)

Say one has two points in the x,y plane. How would one convert those two points to a line? Of course I know you could use the slope-point formula & derive the line as following: $$y - y_0 = \frac{y_1-y_0}{x_1-x_0}(x-x_0)$$ However this manner obviously doesn't hold when $x_1-x_0 = 0$ (vertical line). The more generic approach should however be capable of define every line (vertical line would simply mean B = 0); $$Ax+By +C = 0$$

But how to deduce A, B, C given two points?

• Divide $Ax+By+C=0$ by one of $A,B,C$ whichever is non-zero to eliminate one variable Jun 17, 2013 at 9:06

Let $$P_1:(x_1,y_1)$$ and $$P_2:(x_2,y_2)$$. Then a point $$P:(x,y)$$ lies on the line connecting $$P_1$$ and $$P_2$$ if and only if the area of the parallellogram with sides $$P_1P_2$$ and $$P_1P$$ is zero. This can be expressed using the determinant as $$\begin{vmatrix} x_2-x_1 & x-x_1 \\ y_2-y_1 & y-y_1 \end{vmatrix} = 0 \Longleftrightarrow (y_1-y_2)x+(x_2-x_1)y+x_1y_2-x_2y_1=0,$$ so you get (up to scale) $$A=y_1-y_2$$, $$B=x_2-x_1$$ and $$C=x_1y_2-x_2y_1$$.
• So (y1 - y2) * x + (x2 - x1) * y + (x1 * y2 - x2 * y1) = 0? Oct 29, 2020 at 1:28