Intersection of two lines given by endpoints

Figure 1: Find x and y given x_{11}, y_{11}, x_{12}, y_{12}, x_{21}, y_{21}, x_{22}, y_{22}
Figure 1: Find \(x\) and \(y\) given \(x_{11}\), \(y_{11}\), \(x_{12}\), \(y_{12}\), \(x_{21}\), \(y_{21}\), \(x_{22}\), \(y_{22}\)

Method

\[\begin{align} A &= \frac{y_{12} - y_{11}}{x_{12}-x_{11}} \\ B &= \frac{y_{22} - y_{21}}{x_{22}-x_{21}} \\ x & = \frac{x_{11} A - x_{21} B + y_{21} - y_{11}}{A - B} \\ y & = B(x - x_{21}) + y_{21} \end{align}\]

Derivation

Equation for line 1:

\[\begin{align} \frac{y - y_{11}}{y_{12} - y_{11}} & = \frac{x- x_{11}}{x_{12} - x_{11}} \\ y & = (y_{12} - y_{11})\frac{x - x_{11}}{x_{12} - x_{11}} + y_{11} \label{a}\tag{Eq.1} \end{align}\]

Equation for line 2:

\[\begin{align} \frac{y - y_{21}}{y_{22} - y_{21}} & = \frac{x- x_{21}}{x_{22} - x_{21}} \\ y & = (y_{22} - y_{21})\frac{x - x_{21}}{x_{22} - x_{21}} + y_{21} \label{b}\tag{Eq.2} \end{align}\]

Set \(\ref{a} = \ref{b}\) \[\begin{align} (y_{12} - y_{11})\frac{x - x_{11}}{x_{12} - x_{11}} + y_{11} & = (y_{22} - y_{21})\frac{x - x_{21}}{x_{22} - x_{21}} + y_{21} \\ x \Bigg[ \frac{y_{12} - y_{11}}{x_{12} - x_{11}} - \frac{y_{22} - y_{21}}{x_{22} - x_{21}} \Bigg] & = x_{11}\frac{y_{12} - y_{11}}{x_{12} - x_{11}} - x_{21}\frac{y_{22} - y_{21}}{x_{22} - x_{21}} + y_{21} - y_{11} \end{align}\]

\[\begin{align} \textrm{Let }A & = \frac{y_{12} - y_{11}}{x_{12} - x_{11}} \\ B & = \frac{y_{22} - y_{21}}{x_{22} - x_{21}} \end{align}\]

\[\begin{align} x [ A - B ] & = x_{11} A - x_{21}B + y_{21} - y_{11} \\ x & = \frac{x_{11} A - x_{21} B + y_{21} - y_{11}}{A - B} \\ y & = B(x - x_{21}) + y_{21} \end{align}\]