PDA

View Full Version : matrix methods for equation of a line


zcd
Sep1-11, 08:07 PM
Given two points on R2 how would one find the constants a,b,c such that
ax+by+c=0 gives the line crossing the two points (with matrix methods)?

Simon_Tyler
Sep2-11, 05:35 AM
So you're given the points \vec{p}_1=(x_1, y_1) and \vec{p}_2=(x_2, y_2).

A line is given by the equation


a x + b y
=\begin{pmatrix} a & b \end{pmatrix} \cdot \begin{pmatrix} x \\ y \end{pmatrix}
= c


Which, assuming c \neq 0, can be rescaled to

\begin{pmatrix} a & b \end{pmatrix} \cdot \begin{pmatrix} x \\ y \end{pmatrix} = 1

Then the two points must satisfy
\begin{align}
&\begin{pmatrix} a & b \end{pmatrix}\cdot\begin{pmatrix}x_1&x_2 \\ y_1&y_2\end{pmatrix} = \begin{pmatrix} 1 & 1 \end{pmatrix} \\
\implies
&\begin{pmatrix} a & b \end{pmatrix} = \begin{pmatrix} 1 & 1 \end{pmatrix}
\begin{pmatrix}x_1&x_2 \\ y_1&y_2\end{pmatrix}^{-1}
=\frac{1}{x_1 y_2 - x_2 y_1}\begin{pmatrix} y_1-y_2 & x_1-x_2\end{pmatrix}
\end{align}
And so we have the equation for the line. (This is just Cramer's rule (http://en.wikipedia.org/wiki/Cramer's_rule))

Note that if \det(\vec{p}_1, \vec{p}_2) = x_1 y_2 - x_2 y_1 = 0 \,, (which happens when \vec{p}_1\propto\vec{p}_2)
then the above does not make sense and the line must go through the origin, i.e. c=0.
In which case,
a x = - b y \quad \implies \quad y = -\frac{a}{b}x
and we can just use either point to find the single parameter determining the line
\frac{a}{b} = -\frac{y_1}{x_1} = -\frac{y_2}{x_2} \ .