Finding distance between two parallel 3D lines

I can handle non-parallel lines and the minimum distance between them (by using the projection of the line and the normal vector to both direction vectors in the line), however, in parallel lines, I'm not sure on how to start. I was thinking of finding a normal vector to one of the direction vectors (which will be as well normal to the other line because they are parallel), then set up a line by a point in the direction of the normal vector, and then find the points of intersection. After finding the line between the two parallel lines, then we can calculate the distance.

Is this reasoning correct? If it is, is there a way to find normal vectors to a line or any vector instead of guessing which terms give a scalar product of 0? I have encountered this problem as well in directional derivatives and the like.

• If no one answers this in an hour or so write a comment with "@AlecTeal" in it and I'll answer then. – Alec Teal Nov 27 '13 at 16:32
• There are infinitely many normal vectors (directions) to a line in 3D. – user35603 Nov 27 '13 at 16:37
• First, everything depends on your data. What defines your lines ? Point + direction vector? Also, a normal to a line is a plane. – Jean-Claude Arbaut Nov 27 '13 at 16:39
• You can follow the technique in my answer. – Mhenni Benghorbal Nov 27 '13 at 16:40
• I was thinking, couldn't i as well define the "difference vector" between the two lines (say from an arbitrary point on $L_{1}$ and the equation of the line for $L_{2}$), and then as we have that this difference vector is parallel to one of the direction vectors of the line, calculate the scalar product, equate it to 0 and then find the values of s for which the equality holds? – arcbloom Nov 27 '13 at 16:42

Hint: Let $l_1$ and $l_2$ be parallel lines in 3D. Find a point $A \in l_1$ and then find the distance from $A$ to $l_2$. There is a formula for distance from a point to a line in 3D.
• In $3$ dimensions, such a subspace would be a plane (going through the origin). Every vector in $\mathbb{R}^n$ is normal to exactly one maximal subspace and if two lines are spanned by the same vector, then they share this maximal normal subspace - in this case a plane. – Dan Rust Nov 27 '13 at 17:14
Let $P$ be a variable point of $L_1$ and $P_0$ a fixed point of $L_2$. Try to minimize $$\left|\frac{\mathbf{a}\times\vec{PP_0}}{|\mathbf{a}|}\right|$$ where $\mathbf{a}$ is leading vector (for example) for $L_1$.
Let $r(t) = r_0 + \hat{r} t, \ \ s(t) = s_0 + \hat{r}t$. Then form a triangle with sides $r_0 - s_0$ and one parallel to $\hat{r}$ with length given by $\hat{r} \cdot (r_0 - s_0)$. Then the length of the missing side is your distance.
$d = \sqrt{ |r_0 - s_0|^2 + (\hat{r}(r_0 - s_0))^2}$