Find intersection of two 3D lines

Solution 1:

There are at least two ways to approach such problems, through vectors as such and through coordinates. Some problems are easier one way, and this one is definitely easier via coordinates. Several such solutions have been given. But the more ways you can solve a problem, the better you probably understand the underlying mathematics. So I'll share a vector method.

We can arrive at the solution without the use of coordinates, except as a matter of calculation of the final answer. We also assume that a line is given by a point and a (nonzero) direction vector (in either direction). In the examples given, the lines are defined by two points, but a direction vector may be obtained by taking the difference in the coordinates of the two given points.

Here is the construction. We leave the proof as an exercise, so that the interested reader may benefit by working it out (hint: the Law of Sines is helpful).

Let $\alpha$, $\beta$ be the given lines.

Let $C$, $D$ be points on $\alpha$, $\beta$, resp. If $C$ is on $\beta$ or $D$ is on $\alpha$, we have found the point of intersection. So let us assume they are not.

Let ${\bf e}$ and ${\bf f}$ be direction vectors of $\alpha$, $\beta$, resp. Let ${\bf g} = \vec{CD}$.

Let $h = ||{\bf f} \times {\bf g}||$, $k=||{\bf f} \times {\bf e}||$. If either is $0$, then there is no intersection; otherwise, they are nonzero and proceed.

Let ${\bf l} = {h \over k} {\bf e}$. Then one of $M = C \pm {\bf l}$ is the point of intersection (or depending on the notation you prefer, $\vec{OM} = \vec{OC} \pm {\bf m}$), where the sign may be determined as follows: If ${\bf f} \times {\bf g}$ and ${\bf f} \times {\bf e}$ point in the same direction, then the sign is $+$; otherwise, the sign is $-$.

partial construction

One can compose all the steps to get a formula: $$M = C \pm {||{\bf f} \times {\vec{CD}}|| \over ||{\bf f} \times {\bf e}||}\,{\bf e}\,.$$

If you want to check, we can, in the second example, take $C = (6,8,4)$, $D = (6,8,2)$ and ${\bf e} = (6,7,0)$ and ${\bf f} = (6,7,4)$. Therefore ${\bf g} = \vec{CD} = (0,0,-2)$.

So ${\bf f} \times {\bf g} = (-14, 12,0)$ and ${\bf f} \times {\bf e} = (-28, 24, 0)$, which point in the same direction; so we take the $+$ sign.

Therefore the point of intersection is $C + {1\over2}{\bf e} = (9,{23\over2},4)$.

Solution 2:

The direction numbers $(a,b,c)$ for a line in space may be obtained from two points on the line by subtracting corresponding coordinates. Note that $(a,b,c)$ may be rescaled by multiplying through by any nonzero constant.

The first line has direction numbers $(5,5,2)$ while the second line has direction numbers $(5,5,-2).$ Once one has direction numbers $(a,b,c)$, one can use either given point of the line to obtain the symmetric form of its equation as $$\frac{x-x_0}{a}=\frac{y-y_0}{b}=\frac{z-z_0}{c}.$$ Note that if one or two of $a,b,c$ are $0$ the equation for that variable is obtained by setting the top to zero. That doesn't happen in your case.

Using the given point $(5,5,4)$ of the first line gives its symmetric equation as $$\frac{x-5}{5}=\frac{y-5}{5}=\frac{z-4}{2}.$$ And using the given point $(5,5,5)$ of the second line gives its symmetric form $$\frac{x-5}{5}=\frac{y-5}{5}=\frac{z-5}{-2}.$$ Now if the point $(x,y,z)$ is on both lines, the equation $$\frac{z-4}{2}=\frac{z-5}{-2}$$ gives $z=9/2$, so that the common value for the fractions is $(9/2-4)/2=1/4$. This value is then used to find $x$ and $y$. In this example the equations are both of the same form $(t-5)/5=1/4$ with solution $t=25/4$. So we may conclude the intersection point is $$(25/4,\ 25/4,\ 9/2).$$

ADDED CASE: The OP has asked about another case, which illustrates what happens when one of the direction numbers of one of the two lines is $0$.

Line 1: points $(6,8,4),\ (12,15,4);$ directions $(6,7,0)$, "equation" $$\frac{x-6}{6}=\frac{y-8}{7}=\frac{z-4}{0},$$ where I put equation in quotes because of the division by zero, and as noted the zero denominator of the last fraction means $z=4$ (so $z$ is constant on line 1).

Line 2: points $(6,8,2),\ (12,15,6);$ directions $(6,7,4)$, equation $$\frac{x-6}{6}=\frac{y-8}{8}=\frac{z-2}{4}.$$ Now since we know $z=4$ from line 1 equation, we can use $z=4$ in $(z-2)/4$ of line 2 equation, to get the common fraction value of $(4-2)/4=1/2$. Then from either line, $(x-6)/6=1/2$ so $x=9$, and $(y-8)/7=1/2$ so $y=23/2.$ So for these lines the intersection point is $(9,\ 23/2,\ 4).$

It should be pointed out that two lines in space generally do not intersect, they can be parallel or "skew". This would come out as some contradictory values in the above mechanical procedure.

Solution 3:

$$ \begin{align} \color{#C00000}{((10,10,6)-(5,5,4))}\times\color{#00A000}{((10,10,3)-(5,5,5))} &=\color{#C00000}{(5,5,2)}\times\color{#00A000}{(5,5,-2)}\\ &=\color{#0000FF}{(-20,20,0)} \end{align} $$ is perpendicular to both lines; therefore, $\color{#0000FF}{(-20,20,0)}\cdot u$ is constant along each line. If this constant is not the same for each line, the lines do not intersect. In this case, the constant for each line is $0$, so the lines intersect. $$ \color{#C00000}{(5,5,2)}\times\color{#0000FF}{(-20,20,0)}=\color{#E06800}{(-40,-40,200)} $$ is perpendicular to the first line; therefore, $\color{#E06800}{(-40,-40,200)}\cdot u$ is constant along the first line. In this case, that constant is $400$. The general point along the second line is $$ \color{#00A000}{(5,5,5)}+\color{#00A000}{(5,5,-2)}t $$ To compute the point of intersection, find the $t$ so that $$ \color{#E06800}{(-40,-40,200)}\cdot(\color{#00A000}{(5,5,5)}+\color{#00A000}{(5,5,-2)}t)=400\\ 600-800t=400\\ t=1/4 $$ Plugging $t=1/4$ into the formula for a point along the second line, yields the point of intersection: $$ \color{#00A000}{(5,5,5)}+\color{#00A000}{(5,5,-2)}\cdot1/4=\left(\frac{25}{4},\frac{25}{4},\frac{9}{2}\right) $$


The second example $$ \begin{align} \color{#C00000}{((12,15,4)-(6,8,4))}\times\color{#00A000}{((12,15,6)-(6,8,2))} &=\color{#C00000}{(6,7,0)}\times\color{#00A000}{(6,7,4)}\\ &=\color{#0000FF}{(28,-24,0)} \end{align} $$ is perpendicular to both lines; therefore, $\color{#0000FF}{(28,-24,0)}\cdot u$ is constant along each line. If this constant is not the same for each line, the lines do not intersect. In this case, the constant for each line is $-24$, so the lines intersect. $$ \color{#C00000}{(6,7,0)}\times\color{#0000FF}{(28,-24,0)}=\color{#E06800}{(0,0,-340)} $$ is perpendicular to the first line; therefore, $\color{#E06800}{(0,0,-340)}\cdot u$ is constant along the first line. In this case, that constant is $-1360$. The general point along the second line is $$ \color{#00A000}{(6,8,2)}+\color{#00A000}{(6,7,4)}t $$ To compute the point of intersection, find the $t$ so that $$ \color{#E06800}{(0,0,-340)}\cdot(\color{#00A000}{(6,8,2)}+\color{#00A000}{(6,7,4)}t)=-1360\\ -680-1360t=-1360\\ t=1/2 $$ Plugging $t=1/2$ into the formula for a point along the second line, yields the point of intersection: $$ \color{#00A000}{(6,8,2)}+\color{#00A000}{(6,7,4)}\cdot1/2=\left(9,\frac{23}{2},4\right) $$

Solution 4:

The two lines can be represented as $(5,5,4)+s[(10,10,6)-(5,5,4)]$ and $(5,5,5)+t[(10,10,3)-(5,5,5)]$. To find their intersection means to find $s$ and $t$ such that they are equal.