# Shortest distance between two parallel lines

Let $L_1$ be the line passing through the point $P_1=(4, −2, −3)$ with direction vector $\overrightarrow{d}=[−2, 1, 3]T$, and let $L_2$ be the line passing through the point $P_2=(−2, 3, −2)$ with the same direction vector. Find the shortest distance d between these two lines, and find a point $Q_1$ on $L_1$ and a point $Q_2$ on $L_2$ so that d(Q1,Q2) = d. Use the square root symbol '√' where needed to give an exact value for your answer.

I tried $p_1p_2$, and projected to direction vector $d$, calculated distance wrong. I don't know how to solve the problem.

• Try drawing any line perpendicular to these two and calculating the distance between the two intersections you get. Oct 30 '15 at 20:22
• Draw a picture. What you want to do is subtract the points $P_1$ from the point $P_2$ to get the vector $\vec{P_1P_2}$. Then realize that vector you want (the vector pointing from a point on $L_1$ to the corresponding point on $L_2$) and the vector $\vec{P_1P_2}$ are in the plane $\operatorname{span}(\vec{P_1P_2}, \vec d)$ and the vector you want is orthogonal to $\vec d$. So subtract the projection of $\vec{P_1P_2}$ onto $\operatorname{span}(\vec d)$ from $\vec{P_1P_2}$ to get the vector you want.
– user137731
Oct 30 '15 at 20:34

Notice, a parametric point lying on the line $L_1$ is $A_1(-2t_1+4, t_1-2, 3t_1-3)$ &

parametric point lying on the line $L_2$ is $A_2(-2t_2-2, t_2+3, 3t_2-2)$

Since, $\vec{A_1A_2}=[-2(t_2-t_1)-6, (t_2-t_1)+5, 3(t_2-t_1)+1 ]$ is perpendicular to the direction vector $\vec d=[-2, 1, 3]$ hence we have $(\vec{A_1A_2})\cdot \vec d=0$ (dot product of perpendicular vectors is zero) $$\implies [-2(t_2-t_1)-6, (t_2-t_1)+5, 3(t_2-t_1)+1]\cdot [-2, 1, 3]=0$$ $$14(t_2-t_1)+20=0$$$$\implies t_2-t_1=-\frac{10}{7}$$ setting the value of $t_2-t_1$, we get $$\vec{A_1A_2}=\left[\frac{-22}{7}, \frac{25}{7}, \frac{-23}{7} \right]$$

hence, the shortest distance between the parallel lines $L_1$ & $L_2$ $$=\left|\vec{A_1A_2}\right|=\sqrt{\left(\frac{-22}{7}\right)^2+\left(\frac{25}{7}\right)^2+\left(\frac{-23}{7}\right)^2}$$ $$=\frac{\sqrt{1638}}{7}$$

Hint: Let $\vec p_1=[4,-2,-3]^T$ and $\vec p_2=[-2,3,-2]^T$

The plane orthogonal to the first line passing thorough $P_1$ has equation $\langle\vec d, (\vec x -\vec p_1)\rangle=0$

Intersect this plane with the line passing through $P_2$ tha has equation $\vec d t+\vec p_2=0$ and find the point $Q$ . The distance $P_1Q$ is the distance between the two lines ( and $P_1$ and $Q$ is the couple of point searched).

Here's my very custom take on it.

You need to find a segment going from $L_1$ to $L_2$ and perpendicular to both. Consider the plane $\Pi$ orthogonal to the vector $\overrightarrow{d}$ and, for the sake of easiness, going through $(0,0,0)$. $L_1$ and $L_2$ intersect this plane at points $Q_1$ and $Q_2$. The segment between $Q_1$ and $Q_2$ is the segment you're looking for. (It joins $L_1$ to $L_2$ and is perpendicular them since it belongs to an orthogonal plane). So just compute the distance between $Q_1$ and $Q_2$.

Notice that $Q_1$ and $Q_2$ are respectively the orthogonal projection of $P_1$ and $P_2$ on $\Pi$, as they are the orthogonal projection respectively of any point of $L_1$ or $L_2$.

To find the formula of $\Pi$, remember it is orthogonal to $d$ i.e. have a dot product null with it. Thus you have to the equation

$$\Pi \equiv (x,y,z)\cdot\overrightarrow d = -2\cdot x + y + 3\cdot z = 0$$

Setting $x=1,z=0$ and then $x=0,z=1$, you end up with the basis $(1,2,0),(0,-3,1)$.

This is going to be a method intermediate to those of a number of the other posters, since there are several equivalent ways to describe the vector calculations involved. (In fact, the first way I worked out the distance was essentially that presented by Harish Chandra Rajpoot.)

The parametric expressions for the two lines are $$\ L_1 \ = \ \langle \ 4-2t \ , \ -2 + t \ , \ -3 + 3t \ \rangle \ \$$ and $$\ L_2 \ = \ \langle \ -2-2s \ , \ 3 + s \ , \ -2 + 3s \ \rangle \ \ .$$ We would like to find a vector $$\ \overrightarrow{p} \$$ which is perpendicular to the line direction vector $$\ \overrightarrow{d} \$$ and connects points on the two lines. We are free to choose any third point on either of the lines to define the plane containing the two lines: we may, for instance, take the point on $$\ L_2 \$$ at which $$\ x = 0 \ \ .$$ This is given by $$\ s = -1 \ \ ,$$ giving us $$\ P_3 \ (0 , 2 , -5) \ \ .$$ But since the two lines are parallel, the vector from the given point on one line to the second point on that line will just be a scalar multiple of $$\ \overrightarrow{d} \ \ ,$$ as we will see below.

We are also free to choose any one of our three points as the vertex for two vectors from which we will form the cross-product. So we can take $$\ \overrightarrow{P_2P_1} \ = \ \langle \ 4 - (-2) \ , \ (-2) - 3 \ , \ (-3) - (-2) \ \rangle \ = \ \langle \ 6 \ , \ -5 \ , \ -1 \ \rangle$$ and $$\ \overrightarrow{P_2P_3} \ = \ \langle \ 0 - (-2) \ , \ 2 - 3 \ , \ (-5) - (-2) \ \rangle \ = \ \langle \ 2 \ , \ -1 \ , \ -3 \ \rangle \ = \ -\overrightarrow{d} \ .$$ So in our cross-product calculation, we will simply use $$\ \overrightarrow{d} \$$ as the second vector. A normal vector to the plane is then $$\ \overrightarrow{n} \ = \ \overrightarrow{P_2P_1} \ \times \ \overrightarrow{d} \ = \ \langle \ -14 \ , \ -16 \ , \ -4 \ \rangle \ \ .$$ For simplifying a calculation by hand, we may extract the common factor of $$\ -2 \$$ from these components, as long as we continue using that version of the normal vector hereafter. So we will take $$\ \overrightarrow{n} \ = \ \langle \ 7 \ , \ 8 \ , \ 2 \ \rangle \ \ .$$

The particular orthogonal vector to $$\ \overrightarrow{d} \$$ that we want is then given by the cross-product of $$\ \overrightarrow{n} \$$ with $$\ \overrightarrow{d} \ \ ,$$ $$\ \overrightarrow{p} \ = \ \overrightarrow{n} \ \times \ \overrightarrow{d} \ = \ \langle \ 22 \ , \ -25 \ , \ 23 \ \rangle \ \ .$$

[And if we look at Harish Chandra Rajpoot's solution, we can see what's coming... We can check that we've done this calculation correctly so far by observing that $$\ \overrightarrow{p} \ \cdot \ \overrightarrow{d} \ = \ 22 · 2 \ + \ (-25) · 1 \ + \ 23 · 3 \ \ = \ \ -44 - 25 + 69 \ \ = \ \ 0 \ \ . ]$$

The perpendicular distance between the two parallel lines is now given by the scalar projection of $$\ \overrightarrow{P_2P_1} \ \$$ onto $$\ \overrightarrow{p} \ \ ,$$

$$D \ \ = \ \ \left\vert \ \frac{\overrightarrow{P_2P_1} \ \cdot \ \overrightarrow{p}}{\Vert \ \overrightarrow{p} \ \Vert} \ \right\vert \ \ = \ \ \left\vert \ \frac{6 · 22 \ + \ (-5) · (-25) \ + \ (-1) · 23 }{\sqrt{22^2 \ + \ (-25)^2 \ + \ 23^2}} \ \right\vert \ \ = \ \ \left\vert \ \frac{132 \ + \ 125 \ - \ 23 }{\sqrt{1638}} \ \right\vert$$ $$= \ \ \frac{234}{\sqrt{1638}} \ \ = \ \ \frac{2·3^2·13}{\sqrt{2·3^2·7·13}} \ \ = \ \ \frac{ 3 · \sqrt{2·7·13}}{ 7 } \ \ = \ \ \frac{ 3 · \sqrt{182}}{ 7 } \ \ \approx \ \ 5.78 \ \ .$$

As for the second part of the problem, there is no unique solution. We can take any point on $$\ L_1 \$$ to be $$\ Q_1 \$$ and add to it a vector of length $$\ D \$$ in the direction of $$\ -\overrightarrow{p} \ \ .$$ (The sign of $$\ \overrightarrow{p} \$$ is ambiguous from the cross-product calculation; in order to "run" from $$\ L_1 \$$ to $$\ L_2 \ \ ,$$ we reverse its direction here.) So, for instance, the closest point on $$\ L_2 \$$ to point $$\ P_1 \$$ is

$$(4 , -2 , -3) \ - \ D \ \hat{p} \ \ = \ \ (4 , -2 , -3) \ + \ \left( \frac{234}{\sqrt{1638}} \right) \ \frac{\langle \ -22 \ , \ 25 \ , \ -23 \ \rangle}{\sqrt{1638}}$$ $$= \ \ (4 , -2 , -3) \ + \ \frac{\langle \ -22 \ , \ 25 \ , \ -23 \ \rangle}{7} \ \ = \ \ \left(\frac{6}{7} \ , \ \frac{11}{7} \ , \ -\frac{44}{7} \right) \ \ .$$

[We can verify that this point corresponds to $$\ s = -\frac{10}{7} \$$ on $$\ L_2 \$$ and that the distance between $$\ P_1 \$$ and this point is in fact $$\ D \ \ .$$ ]

$$\ \$$

Another way that is more analytically-based and uses vectors less is to set up a "distance-squared" function for, say, points on $$\ L_2 \$$ measured from point $$\ P_1 \ (t = 0) \$$ on $$\ L_1 \ \ :$$

$$D^2 \ = \ (4 - [-2 - 2s])^2 \ + \ ([-2] - [3 + s])^2 \ + \ ([-3] - [-2 + 3s])^2 \ = \ \Delta(s) \ \ .$$

The extremal value (minimum) is found from

$$\frac{d \Delta}{ds} \ = \ 2 · 2 · (6 + 2s) \ + \ 2 · (-1) · ( -5 - s ) \ + \ 2 · (-3) · ( -1 - 3s ) \ = \ 0$$

[note that this is twice the dot product of the direction vector $$\ \overrightarrow{d} \$$ and the vector from $$\ P_1 \$$ to the closest point to it on $$\ L_2 \$$ : we thereby show, rather than assume, that the closest distance between points on the two parallel lines is the perpendicular distance]

$$\Rightarrow \ \ (12 + 4s) \ - \ (-5 - s) \ - \ (-3 - 9s) \ \ = \ \ 20 + 14s \ \ = \ \ 0 \ \ \Rightarrow \ \ s \ = \ -\frac{10}{7} \ \ ,$$

with the rest of the calculation proceeding as already presented.