VOOZH about

URL: https://www.geeksforgeeks.org/maths/shortest-distance-between-two-lines-in-3d-space-class-12-maths/

⇱ Shortest Distance Between Two Lines in 3D Space - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Shortest Distance Between Two Lines in 3D Space

Last Updated : 12 Dec, 2025

In 3D space, two lines can either intersect at a point, be parallel to each other, or neither intersect nor be parallel, which are referred to as skew lines. The shortest distance between two lines in 3D space is the length of the perpendicular from a point on one line to the other.

When finding the shortest distance between two lines in 3D space, we consider three cases:

  • 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 is the shortest distance.
  • In the case of skew lines, the shortest distance is the line perpendicular to both of the given lines.

The shortest distance can be calculated using vector methods, involving the cross product of direction vectors and the dot product of related vectors. This concept is important in fields like physics, engineering, and computer graphics for tasks like proximity and collision detection.

Note: The alphabets written in bold represent a vector 'x' denotes the 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

Where

  • c and d are the constant vectors,
  • b parallel vector to both the vectors v1 and v2,
  • a1, a2  are the position vectors of some point on v1 and v2, Cartesian respectively.
👁 Shortest-Distance-between-two-Parallel-Lines-with-vector-equations_

How Does It Work?

  • a2 ​− a1​ is a vector between any point on Line 1 and any point on Line 2.
  • (a2​−a1​) × v gives a vector perpendicular to both the connector and the direction of the lines.
  • The magnitude of that cross product gives the area of the parallelogram.
  • Dividing the area by the length of v gives the height of that parallelogram, which is the shortest distance between the lines.

Steps to Calculate the Distance:

  1. Identify points on each line and their direction vectors.
  2. Compute the vector between the points r2 ​− r1​.
  3. Find the cross product of the direction vectors v1​ × v2​.
  4. Compute the dot product of r2​−r1 and v1​ × v2.
  5. Compute the magnitude of the cross product |v1 ​× v2|.
  6. Use the formula to find the shortest distance.

Solved Examples on Shortest Distance Between Two Parallel Lines

Question1: 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)

Here, b = i - j + k
a1 = i -2j
a2 = i - 3j + k
a2 - a1 = -j + k

Thus, |b| = √3 = 1.73
|b × (a2 - a1)| = √2 = 1.41

Shortest distance = |b × (a2 - a1)|/|b| = 1.41/1.73 = 0.815

Question2: For the following lines in 3D space.

  • v1 = i - j - k + (2i - 3j + 4k)
  • v2 = 2i - 3j + k + 3(2i - 3j + 4k)

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)

Here, 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 × (a2 - a1) = 2i - k
|b × (a2 - a1)| = √(2)2 + (1)2 = 2.236

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

Question 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 of V1 is 2i + 3j + 4k, for V2 is 4i + 6j + 8k
The displacement vector V2 is a multiple of V1 as, 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 × (a2 - a1) = 11i - 6j - k 
|b × (a2 - a1)| = 12.569

shortest distance = |b × (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 =

👁 Shortest-Distance-between-two-Skew-Lines-with-vector-equations__

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

Related Articles:

Solved Question on Shortest Distance Between Skew Lines

Question 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
a1 = i - j
a2 = i + j 
⇒ a2 - a1 = 2j

Thus, (b1 × b2) = 7j

Shortest distance = |(b1 × b2)(a2 - a1)|/|(b1 × b2)| = 7j × 2j /7j = 14/7 = 2

Question 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 = |(b1 × b2)(a2 - a1)|/|(b1 × b2)|
b1 = 3i - j + 2k
b2 = i + 3j + 4k
a1 = 2i - j 
a2 = i - j + 2k
⇒ a2 - a1 = -i + 2k

Thus, (b1 × b2) = -10i - 10j + 10k
⇒ |b1 × b2| = 17.320

Thus, |(b1 × b2)(a2 - a1)| = (-10, -10, 10).(-1, 0, 2) = 10 + 0 + 20 = 30
Shortest distance = |30|/10√3 = 3/√3 = √3 = 1.732

Question 3: Given 2 lines in the plane, 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:

The given lines are skew lines.
a1 = i + j 
a2 = 2j + k
b1 = 2i + 3j + 4k
b2 = i + 2j + 3k
⇒ a2 - a1 = (0, 2, 3) - (1, 1, 0) = (-1, 1, 1) = -i + j + k

Thus, (b1 × b2) = i - 2j + k
⇒ |b1 × b2| = 2.44

Shortest distance =|(i - 2j + k)( -3i - j + k)| = √6 = 2.4494.

Numerator:

|(b1 × b2​)⋅(a2 ​− a1​)| = |(1, −2, 1) ⋅ (−1, 1, 1)| = | −1 −2 +1| = | −2| = 2.

Shortest distance is
distance = 2/√6 = √6/3 = 0.8165.

Comment

Explore