# Distance Between Two Lines in 3d

Here you will learn formula to find the distance between two lines in 3d in both vector form and cartesian form with example.

Let’s begin –

## Distance Between Two Lines in 3d

#### (a) Vector Form

Let $$l_1$$ and $$l_2$$ be two lines having vector equations

$$l_1$$ : $$\vec{r}$$ = $$\vec{a_1}$$ + $$\lambda$$$$\vec{b_1}$$

and $$l_2$$ : $$\vec{r}$$ = $$\vec{a_2}$$ + $$\mu$$$$\vec{b_2}$$

The shortest distance (S.D.) between two the two non-parallel lines $$\vec{r}$$ = $$\vec{a_1}$$ + $$\lambda$$$$\vec{b_1}$$ and $$\vec{r}$$ = $$\vec{a_2}$$ + $$\mu$$$$\vec{b_2}$$ is given by

S.D. = |$$(\vec{b_1} \times \vec{b_2}).(\vec{a_2} -\vec{ a_1})\over |\vec{b_1} \times \vec{b_2}|$$|

Condition for two given lines to intersect : If given lines intersect, then the shortest distance between them is zero.

$$(\vec{b_1} \times \vec{b_2}).(\vec{a_2} -\vec{ a_1})$$ = 0

#### (b) Cartesian Form

Let the cartesian equation of two skew lines be

$$x – x_1\over l_1$$ = $$y – y_1\over m_1$$ = $$z – z_1\over n_1$$

and $$x – x_2\over l_2$$ = $$y – y_2\over m_2$$ = $$z – z_2\over n_2$$

Shortest Distance (S.D.) = $$\begin{vmatrix} x_2 – x_1 & y_2 – y_1 & z_2 – z_1 \\ l_1 & m_1 & n_1 \\ l_2 & m_2 & n_2 \end{vmatrix}\over \sqrt{(m_1n_2 – m_2n_1)^2 + (n_1l_1 – l_1n_2)^2 + (l_1m_2 – l_2m_1)^2}$$

Condition for two given lines to intersect : If given lines intersect, then the shortest distance between them is zero.

$$\begin{vmatrix} x_2 – x_1 & y_2 – y_1 & z_2 – z_1 \\ l_1 & m_1 & n_1 \\ l_2 & m_2 & n_2 \end{vmatrix}$$ = 0

Example : Find the shortest distance between the lines

$$\vec{r}$$ = ($$4\hat{i} – \hat{j}$$) + $$\lambda$$($$\hat{i} + 2\hat{j} – 3\hat{k}$$)

and $$\vec{r}$$ = ($$\hat{i} – \hat{j} + 2\hat{k}$$) + $$\mu$$($$2\hat{i} + 4\hat{j} – 5\hat{k}$$)

Solution : We know that the shortest distance between two lines $$\vec{r}$$ = $$\vec{a_1}$$ + $$\lambda$$$$\vec{b_1}$$ and $$\vec{r}$$ = $$\vec{a_2}$$ + $$\mu$$$$\vec{b_2}$$ is given by

d = |$$(\vec{b_1} \times \vec{b_2}).(\vec{a_2} -\vec{ a_1})\over |\vec{b_1} \times \vec{b_2}|$$|

Comparing the given equation with the equations $$\vec{r}$$ = $$\vec{a_1}$$ + $$\lambda$$$$\vec{b_1}$$ and $$\vec{r}$$ = $$\vec{a_2}$$ + $$\mu$$$$\vec{b_2}$$ respectively.

$$\vec{a_1}$$ = $$4\hat{i} – \hat{j}$$, $$\vec{a_2}$$ = $$\hat{i} – \hat{j} + 2\hat{k}$$

and $$\vec{b_1}$$ = $$\hat{i} + 2\hat{j} – 3\hat{k}$$, $$\vec{b_2}$$ = $$2\hat{i} + 4\hat{j} – 5\hat{k}$$

$$a_2 – a_1$$ = $$-3\hat{i} + 0\hat{j} + 2\hat{k}$$

and $$b_1\times b_2$$ = $$\begin{vmatrix} \hat{i} & \hat{j} & \hat{k} \\ 1 & 2 & -3 \\ 2 & 4 & -5 \end{vmatrix}$$ = $$2\hat{i} – \hat{j} + 0\hat{k}$$

($$a_2 – a_1$$).($$b_1\times b_2$$) = $$-3\hat{i} + 0\hat{j} + 2\hat{k}$$.$$2\hat{i} – \hat{j} + 0\hat{k}$$ = -6 + 0 + 0 = 0

and | $$b_1\times b_2$$ | = $$\sqrt{4 + 1 + 0}$$ = $$\sqrt{5}$$

$$\therefore$$ Shortest Distance = |$$(\vec{b_1} \times \vec{b_2}).(\vec{a_2} -\vec{ a_1})\over |\vec{b_1} \times \vec{b_2}|$$|

= |$$-6\over \sqrt{5}$$| = $$6\over \sqrt{5}$$