Linear Algebra – Finding Points on Two Lines a Specific Distance Apart

geometrylinear algebra

I have two linear, skew, 3D lines, and I was wondering how I could find a points on each of the lines whereby the distance between the two points are a particular distance apart?

I'm not after the points where the lines are the closest distance apart, nor the furthest distance apart, nor the point at which the lines cross! I'm after the points on the lines where the two lines are a particular distance apart. I'd like to also be able to change this distance and find the new points.

Thanks very much in advance! 🙂

Best Answer

Here is one way to do it. Assuming you have (or are able to find) a parametric equation for the lines on the form $$\begin{align} l: \begin{cases} x=x_{l0}+at \\ y=y_{l0}+bt \\ z=z_{l0}+ct \end{cases}, \qquad m: \begin{cases} x=x_{m0}+ds \\ y=y_{m0}+es \\ z=z_{m0}+fs \end{cases}. \end{align}$$

Then, $P_0=(x_{l0}+at,y_{l0}+bt,z_{l0}+ct)$ is a general point on the line $l$ and $Q_0=(x_{m0}+ds,y_{m0}+es,z_{m0}+fs)$ a point on $m$.

We can find a vector $\overrightarrow{P_0Q_0}$ from a point on $l$ to a point on $m$: $$\overrightarrow{P_0Q_0} = (x_{m0}+ds-x_{l0}-at,y_{m0}+es-y_{l0}-bt,z_{m0}+fs - z_{l0}-at)$$ The distance of the vector is given by $$||\overrightarrow{P_0Q_0}|| = \sqrt{(x_{m0}+ds-x_{l0}-at)^2 +(y_{m0}+es-y_{l0}-bt)^2 + (z_{m0}+fs - z_{l0}-at)^2}.$$ In other words, if we let $D$ denote your distance, then $$D^2=(x_{m0}+ds-x_{l0}-at)^2 +(y_{m0}+es-y_{l0}-bt)^2 + (z_{m0}+fs - z_{l0}-at)^2 .$$ This may not be the best way to do it. It could be difficult to find a $t$ and an $s$ that fits, and there will probably be several. If you are able to first choose a point on one line, and then find a point on the other line with desired distance, it will be easier and you will only get two solutions (at most).