In short

Two lines in 3D can be skew — neither parallel nor intersecting. The shortest distance between skew lines \vec{r} = \vec{a}_1 + \lambda\vec{b}_1 and \vec{r} = \vec{a}_2 + \mu\vec{b}_2 is d = \frac{|(\vec{a}_2 - \vec{a}_1) \cdot (\vec{b}_1 \times \vec{b}_2)|}{|\vec{b}_1 \times \vec{b}_2|}. Two lines intersect when this distance is zero, and the distance between parallel lines uses the cross-product formula d = \frac{|\vec{AP} \times \vec{b}|}{|\vec{b}|}. The image of a point in a line is found by reflecting through the foot of the perpendicular.

Two metro tunnels run under a city. One goes northeast at a shallow depth; the other goes northwest at a deeper level. They never meet — they are not parallel (they point in different directions), but they also do not cross (they are at different depths). They just pass each other in space, one above the other, without touching.

Lines that behave like this are called skew lines — the uniquely three-dimensional phenomenon that has no analogue in 2D. In a flat plane, two distinct lines either meet or are parallel. In space, there is a third option: they can twist past each other.

The natural question is: how close do the two tunnels get? What is the shortest distance between them? This question — and the formulas that answer it — is the centerpiece of this article.

Image of a point in a line

Before tackling two lines at once, here is a simpler problem that builds on the foot-of-perpendicular technique from the previous article.

The problem. Given a line L and a point P, find the image of P in L — the point P' such that L is the perpendicular bisector of the segment PP'.

Image of a point in a line A line L runs horizontally. Point P is above the line, point P-prime is below, and M is the midpoint of PP-prime lying on the line. The segment PP-prime is perpendicular to L, and PM equals MP-prime. L P P' M d d
The image $P'$ of $P$ in line $L$. The foot of perpendicular $M$ is the midpoint of $PP'$, and the segment $PP'$ is perpendicular to $L$.

The method. Two steps:

  1. Find the foot of perpendicular M from P to L (using the technique from the previous article).
  2. Since M is the midpoint of PP', use the midpoint formula: M = \frac{P + P'}{2}, so P' = 2M - P.

In coordinates: if P = (\alpha, \beta, \gamma) and M = (m_1, m_2, m_3), then

P' = (2m_1 - \alpha,\; 2m_2 - \beta,\; 2m_3 - \gamma)

That is all there is to it. The image is the reflection of the point through the foot of perpendicular.

Why this works

The logic is clean: if L is the perpendicular bisector of PP', then two conditions must hold simultaneously. First, the midpoint of PP' must lie on L. Second, the segment PP' must be perpendicular to L. Both conditions are satisfied by construction: M is on L (it is the foot of perpendicular), PM is perpendicular to L (by definition of the foot of perpendicular), and M is the midpoint of PP' (because we defined P' to make this true).

The image has a physical interpretation. If you placed a mirror along the line L (imagine the line as a thin, flat mirror edge in 3D space), the image P' is where the reflection of P would appear. This is the 3D analogue of reflecting a point across a line in 2D — a technique you may have encountered when studying Locus problems.

A common exam pattern

Many JEE problems ask: "Find the image of the point (a, b, c) in the line \frac{x - x_1}{l} = \frac{y - y_1}{m} = \frac{z - z_1}{n}." The recipe is always the same three steps: (1) parametrise the line, (2) find \lambda using perpendicularity, (3) reflect through the foot. There is no shortcut formula to memorise — the method itself is fast enough.

Shortest distance between two skew lines

This is the main formula of this article, and it is one of the most important results in 3D geometry for entrance exams.

The setup

Two lines in space:

L_1: \vec{r} = \vec{a}_1 + \lambda\vec{b}_1, \qquad L_2: \vec{r} = \vec{a}_2 + \mu\vec{b}_2

These lines are skew — not parallel (\vec{b}_1 is not proportional to \vec{b}_2) and not intersecting (they have no common point).

The shortest distance between them is the length of the segment that is perpendicular to both lines simultaneously. There is exactly one such segment for skew lines, and its direction is along \vec{b}_1 \times \vec{b}_2 — the vector perpendicular to both directions.

Shortest distance between two skew lines Two skew lines L1 and L2 in space, shown at different heights. A perpendicular segment connects the closest points on each line, representing the shortest distance d. The direction of this segment is along the cross product of the two direction vectors. z y x O L₁ L₂ Q₁ Q₂ d b⃗₁ × b⃗₂
Two skew lines $L_1$ and $L_2$ in space. The shortest distance $d$ is the length of the segment $Q_1Q_2$ that is perpendicular to both lines. Its direction is along $\vec{b}_1 \times \vec{b}_2$.

Deriving the formula

The direction perpendicular to both lines is \vec{n} = \vec{b}_1 \times \vec{b}_2.

Pick any point A_1 on L_1 (with position vector \vec{a}_1) and any point A_2 on L_2 (with position vector \vec{a}_2). The vector joining them is \vec{A_1 A_2} = \vec{a}_2 - \vec{a}_1.

The shortest distance is the component of \vec{A_1 A_2} along \vec{n}. To find this component, project \vec{A_1 A_2} onto \vec{n}:

d = \frac{|\vec{A_1 A_2} \cdot \vec{n}|}{|\vec{n}|} = \frac{|(\vec{a}_2 - \vec{a}_1) \cdot (\vec{b}_1 \times \vec{b}_2)|}{|\vec{b}_1 \times \vec{b}_2|}

Why does this work? Think of building a parallelepiped from the three vectors \vec{b}_1, \vec{b}_2, and \vec{A_1 A_2}. The volume of this parallelepiped is |[\vec{A_1 A_2}\;\vec{b}_1\;\vec{b}_2]| = |(\vec{a}_2 - \vec{a}_1) \cdot (\vec{b}_1 \times \vec{b}_2)|. The base of the parallelepiped is the parallelogram spanned by \vec{b}_1 and \vec{b}_2, with area |\vec{b}_1 \times \vec{b}_2|. The height of the parallelepiped — perpendicular to the base — is the shortest distance. So d = \frac{\text{Volume}}{\text{Base area}}.

The numerator is the absolute value of a scalar triple product. The denominator is the magnitude of a cross product. Both should be familiar from the scalar triple product article.

Shortest distance between skew lines

If L_1: \vec{r} = \vec{a}_1 + \lambda\vec{b}_1 and L_2: \vec{r} = \vec{a}_2 + \mu\vec{b}_2 are skew lines, the shortest distance between them is

d = \frac{|(\vec{a}_2 - \vec{a}_1) \cdot (\vec{b}_1 \times \vec{b}_2)|}{|\vec{b}_1 \times \vec{b}_2|}

The Cartesian version

If the lines are given in symmetric form as

L_1: \frac{x - x_1}{a_1} = \frac{y - y_1}{b_1} = \frac{z - z_1}{c_1}, \qquad L_2: \frac{x - x_2}{a_2} = \frac{y - y_2}{b_2} = \frac{z - z_2}{c_2}

then \vec{a}_2 - \vec{a}_1 = (x_2 - x_1)\hat{i} + (y_2 - y_1)\hat{j} + (z_2 - z_1)\hat{k}, and the formula becomes

d = \frac{\left|\begin{vmatrix} x_2 - x_1 & y_2 - y_1 & z_2 - z_1 \\ a_1 & b_1 & c_1 \\ a_2 & b_2 & c_2 \end{vmatrix}\right|}{\sqrt{(b_1 c_2 - b_2 c_1)^2 + (c_1 a_2 - c_2 a_1)^2 + (a_1 b_2 - a_2 b_1)^2}}

The numerator is the absolute value of a 3 \times 3 determinant — the scalar triple product in determinant form. The denominator is the magnitude of \vec{b}_1 \times \vec{b}_2.

Condition for two lines to intersect

Two lines intersect if and only if the shortest distance between them is zero:

(\vec{a}_2 - \vec{a}_1) \cdot (\vec{b}_1 \times \vec{b}_2) = 0

In the determinant form:

\begin{vmatrix} x_2 - x_1 & y_2 - y_1 & z_2 - z_1 \\ a_1 & b_1 & c_1 \\ a_2 & b_2 & c_2 \end{vmatrix} = 0

Why this works. If the scalar triple product is zero, the three vectors \vec{A_1 A_2}, \vec{b}_1, \vec{b}_2 are coplanar — they lie in a common plane. When the join vector from L_1 to L_2 lies in the plane spanned by the two direction vectors, the lines must meet (assuming they are not parallel). The parallelepiped collapses to a flat shape with zero height, meaning the lines are in the same plane — and two non-parallel lines in the same plane always intersect.

This condition is equivalent to saying: there exist values of \lambda and \mu such that \vec{a}_1 + \lambda\vec{b}_1 = \vec{a}_2 + \mu\vec{b}_2. You can check this condition by solving the resulting system of three equations in two unknowns (\lambda and \mu). If the system is consistent — if all three equations are satisfied by the same \lambda and \mu — the lines intersect. The determinant condition is a faster test.

Intersecting vs skew lines Two diagrams side by side. On the left, two lines meet at a single point — the parallelepiped has zero volume. On the right, two lines are skew — they miss each other and the parallelepiped has positive volume. Intersecting (d = 0) L₁ L₂ intersection Skew (d > 0) L₁ L₂ d
Left: two intersecting lines — the scalar triple product is zero and the shortest distance is zero. Right: two skew lines — the scalar triple product is non-zero and there is a positive shortest distance $d$ between them.

Distance between parallel lines

When \vec{b}_1 and \vec{b}_2 are proportional (the lines are parallel), the cross product \vec{b}_1 \times \vec{b}_2 = \vec{0}, so the skew-lines formula gives \frac{0}{0} — undefined. Parallel lines need a different formula.

The idea. If the two lines are parallel with common direction \vec{b}, pick any point A_2 on L_2 and find its perpendicular distance to L_1. This distance is the same regardless of which point on L_2 you choose (because the lines are parallel).

Distance between parallel lines Two parallel lines L1 and L2 with the same direction vector b. A point A1 on L1 and a point A2 on L2 are marked. The perpendicular from A2 to L1 has length d. The vector from A1 to A2 and the direction vector b form a parallelogram whose height is d. L₁ L₂ A₁ A₂ A₁A₂ d b⃗
Parallel lines $L_1$ and $L_2$. The distance $d$ between them is the perpendicular distance from any point on $L_2$ to $L_1$.

Using the cross-product formula from the previous article, with \vec{AP} = \vec{a}_2 - \vec{a}_1 and direction \vec{b} (common to both lines):

Distance between parallel lines

d = \frac{|(\vec{a}_2 - \vec{a}_1) \times \vec{b}|}{|\vec{b}|}

This is exactly the perpendicular-distance-from-point-to-line formula, applied with A_2 as the point and L_1 as the line.

Two worked examples

Example 1: Shortest distance between skew lines

Find the shortest distance between the lines

L_1: \frac{x - 1}{2} = \frac{y - 2}{3} = \frac{z - 3}{4}, \qquad L_2: \frac{x - 2}{3} = \frac{y - 4}{4} = \frac{z - 5}{5}

Step 1. Identify the points and direction vectors.

\vec{a}_1 = \hat{i} + 2\hat{j} + 3\hat{k}, \quad \vec{b}_1 = 2\hat{i} + 3\hat{j} + 4\hat{k}
\vec{a}_2 = 2\hat{i} + 4\hat{j} + 5\hat{k}, \quad \vec{b}_2 = 3\hat{i} + 4\hat{j} + 5\hat{k}

Why: the point comes from the numerators in the symmetric form, and the direction ratios from the denominators.

Step 2. Compute \vec{a}_2 - \vec{a}_1.

\vec{a}_2 - \vec{a}_1 = (2-1)\hat{i} + (4-2)\hat{j} + (5-3)\hat{k} = \hat{i} + 2\hat{j} + 2\hat{k}

Why: this is the vector joining the two known points, one on each line.

Step 3. Compute \vec{b}_1 \times \vec{b}_2.

\vec{b}_1 \times \vec{b}_2 = \begin{vmatrix} \hat{i} & \hat{j} & \hat{k} \\ 2 & 3 & 4 \\ 3 & 4 & 5 \end{vmatrix}
= (15 - 16)\hat{i} - (10 - 12)\hat{j} + (8 - 9)\hat{k} = -\hat{i} + 2\hat{j} - \hat{k}

Why: the cross product gives the direction perpendicular to both lines. Since it is non-zero, the lines are not parallel.

Step 4. Compute the scalar triple product (numerator).

(\vec{a}_2 - \vec{a}_1) \cdot (\vec{b}_1 \times \vec{b}_2) = (1)(-1) + (2)(2) + (2)(-1) = -1 + 4 - 2 = 1

Why: this is the volume of the parallelepiped formed by the three vectors.

Step 5. Compute the magnitude of the cross product (denominator).

|\vec{b}_1 \times \vec{b}_2| = \sqrt{(-1)^2 + 2^2 + (-1)^2} = \sqrt{1 + 4 + 1} = \sqrt{6}

Why: the base area of the parallelepiped.

Result: d = \dfrac{|1|}{\sqrt{6}} = \dfrac{1}{\sqrt{6}} = \dfrac{\sqrt{6}}{6}.

A 2D projection of the two skew lines. In this projection, the lines appear nearly coincident — their directions $(2,3,4)$ and $(3,4,5)$ are close. The true separation is the small distance $\frac{1}{\sqrt{6}} \approx 0.41$, which comes from the slight twist in the $z$-direction that the flat projection hides.

The shortest distance is small — about 0.41 units. The two lines are nearly parallel (their direction vectors differ only by (\hat{i} + \hat{j} + \hat{k}), making them close in direction) and they pass close to each other.

Example 2: Checking intersection and finding the image of a point

Two lines are given:

L_1: \frac{x - 1}{1} = \frac{y}{-1} = \frac{z + 1}{1}, \qquad L_2: \frac{x - 2}{2} = \frac{y + 1}{1} = \frac{z}{-1}

(a) Do the lines intersect? (b) Find the image of the point P = (5, -2, 1) in the line L_1.

(a) Intersection check.

Step 1. Set up the data.

\vec{a}_1 = \hat{i} + 0\hat{j} - \hat{k}, \quad \vec{b}_1 = \hat{i} - \hat{j} + \hat{k}
\vec{a}_2 = 2\hat{i} - \hat{j} + 0\hat{k}, \quad \vec{b}_2 = 2\hat{i} + \hat{j} - \hat{k}
\vec{a}_2 - \vec{a}_1 = \hat{i} - \hat{j} + \hat{k}

Why: read off from the symmetric forms.

Step 2. Compute \vec{b}_1 \times \vec{b}_2.

\vec{b}_1 \times \vec{b}_2 = \begin{vmatrix} \hat{i} & \hat{j} & \hat{k} \\ 1 & -1 & 1 \\ 2 & 1 & -1 \end{vmatrix} = (1 - 1)\hat{i} - (-1 - 2)\hat{j} + (1 + 2)\hat{k} = 0\hat{i} + 3\hat{j} + 3\hat{k}

Why: the cross product is non-zero, so the lines are not parallel.

Step 3. Compute the scalar triple product.

(\vec{a}_2 - \vec{a}_1) \cdot (\vec{b}_1 \times \vec{b}_2) = (1)(0) + (-1)(3) + (1)(3) = 0 - 3 + 3 = 0

Why: if this is zero, the lines are coplanar and must intersect.

The scalar triple product is zero, so yes, the lines intersect.

(b) Image of P = (5, -2, 1) in L_1.

Step 3. A general point on L_1 is M = (1 + \lambda,\; -\lambda,\; -1 + \lambda).

\vec{PM} = (1 + \lambda - 5)\hat{i} + (-\lambda + 2)\hat{j} + (-1 + \lambda - 1)\hat{k} = (\lambda - 4)\hat{i} + (2 - \lambda)\hat{j} + (\lambda - 2)\hat{k}

Why: \vec{PM} = M - P.

Step 4. Apply \vec{PM} \cdot \vec{b}_1 = 0.

1(\lambda - 4) + (-1)(2 - \lambda) + 1(\lambda - 2) = 0
\lambda - 4 - 2 + \lambda + \lambda - 2 = 0
3\lambda - 8 = 0 \implies \lambda = \frac{8}{3}

Why: the foot of perpendicular must satisfy perpendicularity with the direction of the line.

Step 5. Find M and then P'.

M = \left(1 + \frac{8}{3},\; -\frac{8}{3},\; -1 + \frac{8}{3}\right) = \left(\frac{11}{3},\; -\frac{8}{3},\; \frac{5}{3}\right)
P' = 2M - P = \left(\frac{22}{3} - 5,\; -\frac{16}{3} + 2,\; \frac{10}{3} - 1\right) = \left(\frac{7}{3},\; -\frac{10}{3},\; \frac{7}{3}\right)

Why: the image is the reflection through the foot — M is the midpoint of PP', so P' = 2M - P.

Result: (a) The lines intersect. (b) The image of (5, -2, 1) in L_1 is \left(\dfrac{7}{3},\; -\dfrac{10}{3},\; \dfrac{7}{3}\right).

The $x$-$y$ projection showing $L_1$, the point $P(5, -2, 1)$, the foot $M(\frac{11}{3}, -\frac{8}{3}, \frac{5}{3})$, and the image $P'(\frac{7}{3}, -\frac{10}{3}, \frac{7}{3})$. The segment $PP'$ is bisected by $M$ on the line.

Verification. Check that M is the midpoint of PP': \frac{5 + 7/3}{2} = \frac{22/3}{2} = \frac{11}{3}, \frac{-2 + (-10/3)}{2} = \frac{-16/3}{2} = \frac{-8}{3}, \frac{1 + 7/3}{2} = \frac{10/3}{2} = \frac{5}{3}. All components match M. The image is correct.

Common confusions

Going deeper

If you came here to learn the key formulas and how to apply them, you have everything you need — you can stop here. The rest explores why these formulas work from a deeper geometric viewpoint, and what happens in degenerate cases.

Finding the actual closest points

The shortest-distance formula gives you the distance but not the points where the common perpendicular meets the two lines. To find these points, set up the parametric equations:

Q_1 = \vec{a}_1 + \lambda\vec{b}_1, \qquad Q_2 = \vec{a}_2 + \mu\vec{b}_2

The vector \vec{Q_1 Q_2} must be perpendicular to both \vec{b}_1 and \vec{b}_2:

\vec{Q_1 Q_2} \cdot \vec{b}_1 = 0, \qquad \vec{Q_1 Q_2} \cdot \vec{b}_2 = 0

Expanding \vec{Q_1 Q_2} = (\vec{a}_2 + \mu\vec{b}_2) - (\vec{a}_1 + \lambda\vec{b}_1) = (\vec{a}_2 - \vec{a}_1) + \mu\vec{b}_2 - \lambda\vec{b}_1, the two dot-product conditions give two linear equations in \lambda and \mu. Solve for both, and substitute back to get Q_1 and Q_2.

The parallelepiped picture

The derivation used the fact that |(\vec{a}_2 - \vec{a}_1) \cdot (\vec{b}_1 \times \vec{b}_2)| is the volume of the parallelepiped built on three edges. This is worth visualising.

The base of the parallelepiped is the parallelogram spanned by \vec{b}_1 and \vec{b}_2, with area |\vec{b}_1 \times \vec{b}_2|. The third edge is \vec{a}_2 - \vec{a}_1. The height of the parallelepiped — the component of \vec{a}_2 - \vec{a}_1 perpendicular to the base — is the shortest distance. So the shortest distance is not pulled out of thin air; it is the natural measure of how much the two lines fail to be coplanar.

When the two lines are coplanar (they intersect or are parallel), the parallelepiped collapses to zero volume, and the shortest distance is zero — which is exactly the intersection condition.

Finding the closest points: a worked derivation

Take the skew lines from Example 1: L_1 through (1,2,3) with direction (2,3,4), and L_2 through (2,4,5) with direction (3,4,5). The closest points are Q_1 = (1 + 2\lambda,\; 2 + 3\lambda,\; 3 + 4\lambda) on L_1 and Q_2 = (2 + 3\mu,\; 4 + 4\mu,\; 5 + 5\mu) on L_2.

The vector \vec{Q_1 Q_2} = (1 + 3\mu - 2\lambda)\hat{i} + (2 + 4\mu - 3\lambda)\hat{j} + (2 + 5\mu - 4\lambda)\hat{k}.

The condition \vec{Q_1 Q_2} \cdot \vec{b}_1 = 0 gives:

2(1 + 3\mu - 2\lambda) + 3(2 + 4\mu - 3\lambda) + 4(2 + 5\mu - 4\lambda) = 0
2 + 6\mu - 4\lambda + 6 + 12\mu - 9\lambda + 8 + 20\mu - 16\lambda = 0
16 + 38\mu - 29\lambda = 0 \quad \ldots (i)

The condition \vec{Q_1 Q_2} \cdot \vec{b}_2 = 0 gives:

3(1 + 3\mu - 2\lambda) + 4(2 + 4\mu - 3\lambda) + 5(2 + 5\mu - 4\lambda) = 0
3 + 9\mu - 6\lambda + 8 + 16\mu - 12\lambda + 10 + 25\mu - 20\lambda = 0
21 + 50\mu - 38\lambda = 0 \quad \ldots (ii)

From (i): 38\mu = 29\lambda - 16, so \mu = \frac{29\lambda - 16}{38}. Substitute into (ii):

21 + 50 \cdot \frac{29\lambda - 16}{38} - 38\lambda = 0
21 + \frac{1450\lambda - 800}{38} - 38\lambda = 0

Multiply through by 38: 798 + 1450\lambda - 800 - 1444\lambda = 0, so 6\lambda = 2, giving \lambda = \frac{1}{3}.

Then \mu = \frac{29/3 - 16}{38} = \frac{(29 - 48)/3}{38} = \frac{-19}{114} = -\frac{1}{6}.

The closest points are Q_1 = (1 + \frac{2}{3},\; 2 + 1,\; 3 + \frac{4}{3}) = (\frac{5}{3}, 3, \frac{13}{3}) and Q_2 = (2 - \frac{1}{2},\; 4 - \frac{2}{3},\; 5 - \frac{5}{6}) = (\frac{3}{2}, \frac{10}{3}, \frac{25}{6}).

You can verify: |Q_1 Q_2| = \sqrt{(\frac{5}{3} - \frac{3}{2})^2 + (3 - \frac{10}{3})^2 + (\frac{13}{3} - \frac{25}{6})^2} = \sqrt{\frac{1}{36} + \frac{1}{9} + \frac{1}{36}} = \sqrt{\frac{1 + 4 + 1}{36}} = \frac{\sqrt{6}}{6}, matching the distance found in Example 1.

When one direction ratio is zero

If a direction ratio is zero — say c_1 = 0 in the first line — the symmetric form is often written as \frac{x - x_1}{a_1} = \frac{y - y_1}{b_1} = \frac{z - z_1}{0}. This is shorthand for z = z_1 (the z-coordinate is constant along the line). The formulas for shortest distance, intersection, and perpendicular distance work exactly the same way — plug in c_1 = 0 and compute. No special treatment is needed.

The matrix viewpoint

The intersection condition [\vec{A_1A_2}\;\vec{b}_1\;\vec{b}_2] = 0 is a coplanarity condition. In the language of matrices, the three vectors \vec{A_1 A_2}, \vec{b}_1, \vec{b}_2 are linearly dependent — they do not span all of 3D space. The determinant of the 3 \times 3 matrix with these vectors as rows is zero. This connects the geometry of lines to the algebra of determinants — a recurring theme in 3D geometry.

The three relationships between two lines in 3D

It is worth collecting the complete classification. Two distinct lines in 3D are in exactly one of these three relationships:

Relationship \vec{b}_1 \times \vec{b}_2 Scalar triple product Distance
Intersecting \neq \vec{0} = 0 0
Parallel = \vec{0} (not applicable) > 0 (or = 0 if same line)
Skew \neq \vec{0} \neq 0 > 0

This table is the complete decision tree. First check if the cross product is zero (parallel or not). If not parallel, check the scalar triple product (intersecting or skew). Each case has its own distance formula.

Where this leads next

You have now seen how two lines in 3D interact — through angles, distances, and intersection conditions. The next natural step is to study the plane, where a flat surface replaces a one-dimensional line.