In 3D space, two lines can either intersect each other at some point, parallel to each other or they can neither be intersecting nor parallel to each other also known as skew lines.

- In the case of intersecting lines the shortest distance between them is 0.
- For parallel lines, the length of the line joining the two parallel lines or the length of the line perpendicular to both the parallel lines has the shortest distance.
- In the case of skew lines, the shortest distance is the line perpendicular to both of the given lines.

Note:The alphabets written in bold represent vector. ‘x’ denotes cross product(vector product).

**Shortest Distance Between **Two** Parallel Lines **

Considering 2 lines in vector form as:

**v1** = **a1** + c * **b**

**v2** = **a2** + d * **b**

Here, c and d are the constants.

**b = **parallel vector to both the vectors **v1** and **v2**

**a1, a2 ** are the position vector of some point on **v1 **and **v2 **respectively

Shortest distance = |b x (a2 – a1)| / |b|

### Examples

**Example** **1: For the following lines in 3D space.**

**v1 = i – 2j + i – j + k**

**v2 = i – 3j + k + i – j + k**

**Find the shortest distance between these lines?**

**Solution:**

v1: i – 2j + i – j + k

v2: i – 3j + k + i – j + k

b = i – j + k

a1 = i -2j

a2 = i – 3j + k

a2 – a1 = -j + k

|b| = √3 = 1.73

|b x(a2–a1)| = √2 = 1.41

Shortest distance = |b x(a2–a1)|/|b| = 1.41/1.73 = 0.815

**Example 2: For the following lines in 3D space.**

**v1 = i – j – k + 2i – 3j + 4k**

**v2 = 2i – 3j + k + 6i – 9j + 12k**

**Find the shortest distance between these lines?**

**Solution: **

The vector can be written in form as:

v1 = i – j – k + 2i – 3j + 4k

v2 = 2i – 3j + k + 3 * (2i – 3j + 4k)

b = 2i – 3j + 4k

|b| = √(2)^{2}+ (-3)^{2}+ (4)^{2}= 5.385

a1=i–j–k

a2= 2i– 3j+k

a2–a1=i– 2j+ 2k

b x(a2–a1) = 2i–k

|bx(a2–a1)| = √(2)^{2}+ (1)^{2 }= 2.236

Now applying the shortest distance formula for parallel lines = |bx(a2–a1)|/|b| = 2.236/5.385 = 0.415

**Example 3: Given two lines in the cartesian format as:**

**V1: (x – 2)/2 = (y – 1)/3 = (z)/4**

**V2: (x – 3)/4 = (y – 2)/6 = (z – 5)/8**

**Find the shortest distance between these lines.**

**Solution:**

The displacement vector ofV1is2i + 3j + 4k, forV2is4i + 6j + 8k

The displacement vectorV2is a multiple ofV1as,

4i + 6j + 8k= 2 * (2i + 3j + 4k)

So the two given lines are parallel to each other.

a1 = 2i + j + 0k

a2 = 3i + 2j + 5k

a2 – a1 = i + j +5k

b = 2i + 3j + 4k

|b| =√(2)^{2}+ (3)^{2}+ (4)^{2 }= 5.385

b x (a2 – a1)=11i – 6j – k

|b x (a2 – a1)|= 12.569

shortest distance = |b x (a2 – a1)|/|b|= 12.569/5.385 = 2.334

**Shortest Distance Between Skew Lines**

Considering 2 lines in vector form as:

**v1** = **a1** + c *** b1**

**v2** = **a2** + d * **b2**

here, c and d are the constants.

The shortest distance 2 skew lines = |(b1 x b2)(a2 – a1)|/|(b1 x b2)|

Note: If two lines are intersecting then’s the shortest distance considering the two lines skew will automatically come out to be zero.

### Examples

**Example 1: Given two lines in vector form as:**

**V1: i – j + 2i + j + k**

**V2: i + j + 3i – j – k**

**Find the shortest distance between these lines.**

**Solution:**

The given lines are skew lines.

b1 = 2i + j + k

b2 = 3i – j – k

a2 = i + j

a1 = i – j

a2 – a1 = 2j

(b1 x b2) = 5j – 5k

Shortest distance = |(b1 x b2)(a2 – a1)|/|(b1 x b2)| = 10/7.07 = 1.41

**Example 2: Given two lines in vector form as:**

**V1: 2i – j + 5 * (3i – j + 2k)**

**v2: i – j + 2k + 2* (i + 3j + 4k)**

**Find the shortest distance between these lines.**

**Solution:**

The given lines are skew lines.

Shortest distance = |(b1xb2)(a2–a1)|/|(b1xb2)|

b1 = 3i – j + 2k

b2 = i + 3j + 4k

a1 = 2i – j

a2 = i – j + 2k

a2 – a1 = -i + 2k

(b1 x b2)=-10i – 10j + 10k

|b1 xb2| = 17.320

|(b1 x b2)(a2 –a1)| = 40

Shortest distance = 40/17.320 = 2.309

**Example 3: Given 2 lines in the cartesian form, find the shortest distance between them.**

**V1: (x – 1)/2 = (y – 1)/3 = (z)/4**

**V2: (x)/1 = (y – 2)/2 = (z – 1)/3 **

**Solution:**

a1 = i + j

a2 = -2j + k

b1 = 2i + 3j + 4k

b2 = i + 2j + 3k

a2 – a1 = -3i – j + k

(b1 x b2) = i – 2j + k

|b1 x b2| = 2.44

Shortest distance =|(i – 2j + k)(-3i – j + k)|/2.44 = 0

Since, shortest distance is zero it means these two lines are intersecting lines.

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the **DSA Self Paced Course** at a student-friendly price and become industry ready.