[Math] How to find intersection of two lines in 3D

geometrylinear algebra

Given two lines joining A,B and C, D in 3D how do I figure out if they intersect, where they intersect and the ratio along AB at which the intersection happens?

I can quite hapilly work out the equation for the lines in different forms. I'm guessing that you need to change them to parametric form, equate the equations and do some algebra manipulation

Best Answer

If you are given two points for each line, $A=(a_1,a_2,a_3)$, $B=(b_1,b_2,b_3)$ to determine the first line, $C=(c_1,c_2,c_3)$ and $D=(d_1,d_2,d_3)$ to the determine the second line, the simplest way is to write both lines in vector/parametric form:

  • Line $1$ through $A$ and $B$ has vector form $$\left(\begin{array}{c}x\\y\\z\end{array}\right) = A + t(B-A) = \left(\begin{array}{c}a_1\\a_2\\a_3\end{array}\right) + t\left(\begin{array}{c}b_1-a_1\\b_2-a_2\\b_3-a_3\end{array}\right),\quad t\in\mathbb{R}.$$

  • Line $2$ through $C$ and $D$ has vector form $$\left(\begin{array}{c}x\\y\\z\end{array}\right) = C + s(D-C) = \left(\begin{array}{c}c_1\\c_2\\c_3\end{array}\right) + s\left(\begin{array}{c}d_1-c_1\\d_2-c_2\\d_3-c_3\end{array}\right),\quad s\in\mathbb{R}.$$

The two lines intersect if and only if there is a solution $s,t$ to the system of linear equations $$\begin{array}{rcl} a_1 + t(b_1-a_1) &= c_1 + s(d_1-c_1)\\ a_2 + t(b_2-a_2) &= c_2 + s(d_2-c_2)\\ a_3 + t(b_3-a_3) &= c_3 + s(d_3-c_3). \end{array}$$ If $(s_0,t_0)$ is a solution to this system, then plugging in $t_0$ to the equation for $L_1$ or $s_0$ to the equation for $L_2$ yields thep oint of intersection.

I confess i don't know what "The ratio at which the intersection happens" means. Perhaps it refers to the value of $t$ (which is $0$ for the point $A$ and $1$ for the point $B$, and for example $t = \frac{1}{2}$ for the point midway between $A$ and $B$).