PGD01C01
Module 4 · Vectors and Geometry of Space

Distances in Space

Core Titles
Key headlines and terms for quick recall
  • Distance between two points: (xiyi)2\sqrt{\sum (x_i - y_i)^2}
  • Point to plane: ax0+by0+cz0+da2+b2+c2\dfrac{|ax_0 + by_0 + cz_0 + d|}{\sqrt{a^2 + b^2 + c^2}}
  • Point to line: AP×dd\dfrac{\|\vec{AP} \times \vec{d}\|}{\|\vec{d}\|}
  • Distance between parallel lines / parallel planes
  • Skew lines — shortest distance via (r2r1)(d1×d2)d1×d2\dfrac{|(\vec{r}_2 - \vec{r}_1) \cdot (\vec{d}_1 \times \vec{d}_2)|}{\|\vec{d}_1 \times \vec{d}_2\|}
Basic Idea
What it is, why it matters, how it works

Two-point distance

d(A,B)=(x2x1)2+(y2y1)2+(z2z1)2d(A, B) = \sqrt{(x_2-x_1)^2 + (y_2-y_1)^2 + (z_2-z_1)^2}

Point to plane

For plane ax+by+cz+d=0ax + by + cz + d = 0 and point P0(x0,y0,z0)P_0(x_0, y_0, z_0): d=ax0+by0+cz0+da2+b2+c2.d = \frac{|a x_0 + b y_0 + c z_0 + d|}{\sqrt{a^2 + b^2 + c^2}}. Idea: project r0p\vec{r}_0 - \vec{p} (where p\vec{p} is any point on the plane) onto the normal n\vec{n}.

Point to line

Line through AA with direction d\vec{d}. For point PP: d(P,L)=AP×dd.d(P, L) = \frac{\|\vec{AP} \times \vec{d}\|}{\|\vec{d}\|}. Idea: the cross product's magnitude is the area of the parallelogram with sides AP\vec{AP} and d\vec{d}; dividing by d\|\vec{d}\| gives the perpendicular height.

Two parallel planes

Take the constant difference; for ax+by+cz=d1ax+by+cz = d_1 and ax+by+cz=d2ax+by+cz = d_2: d=d1d2a2+b2+c2.d = \frac{|d_1 - d_2|}{\sqrt{a^2 + b^2 + c^2}}.

Skew lines (non-parallel, non-intersecting)

For lines r=r1+td1\vec{r} = \vec{r}_1 + t \vec{d}_1 and r=r2+sd2\vec{r} = \vec{r}_2 + s \vec{d}_2: d=(r2r1)(d1×d2)d1×d2.d = \frac{|(\vec{r}_2 - \vec{r}_1) \cdot (\vec{d}_1 \times \vec{d}_2)|}{\|\vec{d}_1 \times \vec{d}_2\|}. Idea: d1×d2\vec{d}_1 \times \vec{d}_2 is perpendicular to both lines, so the projection of the joining vector r2r1\vec{r}_2 - \vec{r}_1 onto this normal is the shortest distance.

Why this matters in Data Science

Distance-to-hyperplane is central to SVM margin and any classification confidence measure. Anomaly detection often computes distance to subspaces.

Mind Map
Visual structure of the concept
DISTANCES IN SPACE
├── Point ↔ Point: √Σ(xᵢ − yᵢ)²
├── Point ↔ Plane:  |ax₀+by₀+cz₀+d| / √(a²+b²+c²)
├── Point ↔ Line:   ‖AP × d‖ / ‖d‖
├── Parallel planes:  |d₁ − d₂| / ‖n‖
└── Skew lines:  |(r₂−r₁)·(d₁×d₂)| / ‖d₁×d₂‖
Exam Q&A
Part A (2 marks) and Part B (20 marks) style questions

Part A (2 marks each)

Q1. Distance between points (1,2,3)(1,2,3) and (4,6,3)(4,6,3). 9+16+0=5\sqrt{9 + 16 + 0} = 5.

Q2. Write the formula for distance from point to plane. d=ax0+by0+cz0+da2+b2+c2d = \dfrac{|a x_0 + b y_0 + c z_0 + d|}{\sqrt{a^2 + b^2 + c^2}}.

Q3. Find the distance from (1,1,1)(1,1,1) to the plane 2x+y2z+3=02x + y - 2z + 3 = 0. d=2+12+34+1+4=43d = \dfrac{|2 + 1 - 2 + 3|}{\sqrt{4 + 1 + 4}} = \dfrac{4}{3}.

Q4. What are skew lines? Two lines in 3D that are neither parallel nor intersecting.


Part B (20 marks)

Q. Derive the formula for the perpendicular distance from a point to a plane. Find the shortest distance between the skew lines r=i^+2j^4k^+t(2i^+3j^+6k^)\vec{r} = \hat{i} + 2\hat{j} - 4\hat{k} + t(2\hat{i} + 3\hat{j} + 6\hat{k}) and r=3i^+3j^5k^+s(2i^+3j^+6k^)\vec{r} = 3\hat{i} + 3\hat{j} - 5\hat{k} + s(2\hat{i} + 3\hat{j} + 6\hat{k}). (Note: the two lines are parallel — adjust the example.)

We treat the second line as r=3i^+3j^5k^+s(i^+2j^+3k^)\vec{r} = 3\hat{i} + 3\hat{j} - 5\hat{k} + s(\hat{i} + 2\hat{j} + 3\hat{k}) so that the lines are truly skew.

Point-to-plane distance — derivation.

Let the plane be Π:ax+by+cz+d=0\Pi : ax + by + cz + d = 0, with normal n=(a,b,c)\vec{n} = (a, b, c). Let P0=(x0,y0,z0)P_0 = (x_0, y_0, z_0) and let QQ be the foot of perpendicular from P0P_0 on Π\Pi.

Then P0Q=λn\vec{P_0 Q} = \lambda \vec{n} for some scalar λ\lambda, so Q=P0+λnQ = P_0 + \lambda \vec{n}. Since QQ lies on Π\Pi: a(x0+λa)+b(y0+λb)+c(z0+λc)+d=0a(x_0 + \lambda a) + b(y_0 + \lambda b) + c(z_0 + \lambda c) + d = 0 (ax0+by0+cz0+d)+λ(a2+b2+c2)=0\Rightarrow (a x_0 + b y_0 + c z_0 + d) + \lambda (a^2 + b^2 + c^2) = 0 λ=ax0+by0+cz0+da2+b2+c2.\Rightarrow \lambda = -\dfrac{a x_0 + b y_0 + c z_0 + d}{a^2 + b^2 + c^2}.

The perpendicular distance is d(P0,Π)=λn=ax0+by0+cz0+da2+b2+c2.d(P_0, \Pi) = |\lambda| \|\vec{n}\| = \frac{|a x_0 + b y_0 + c z_0 + d|}{\sqrt{a^2 + b^2 + c^2}}. \quad \blacksquare

Shortest distance between skew lines.

Lines: L1:r1=(1,2,4)+t(2,3,6)L_1 : \vec{r}_1 = (1, 2, -4) + t(2, 3, 6), d1=(2,3,6)\vec{d}_1 = (2, 3, 6). L2:r2=(3,3,5)+s(1,2,3)L_2 : \vec{r}_2 = (3, 3, -5) + s(1, 2, 3), d2=(1,2,3)\vec{d}_2 = (1, 2, 3).

Step 1 — d1×d2\vec{d}_1 \times \vec{d}_2. d1×d2=i^j^k^236123=i^(912)j^(66)+k^(43)=3i^+0j^+k^\vec{d}_1 \times \vec{d}_2 = \begin{vmatrix} \hat{i} & \hat{j} & \hat{k} \\ 2 & 3 & 6 \\ 1 & 2 & 3 \end{vmatrix} = \hat{i}(9 - 12) - \hat{j}(6 - 6) + \hat{k}(4 - 3) = -3\hat{i} + 0\hat{j} + \hat{k}.

Magnitude: 9+0+1=10\sqrt{9 + 0 + 1} = \sqrt{10}.

Step 2 — Joining vector. r2r1=(2,1,1)\vec{r}_2 - \vec{r}_1 = (2, 1, -1).

Step 3 — Dot with d1×d2\vec{d}_1 \times \vec{d}_2. (2)(3)+(1)(0)+(1)(1)=6+01=7(2)(-3) + (1)(0) + (-1)(1) = -6 + 0 - 1 = -7.

Step 4 — Shortest distance. d=710=710=71010.d = \frac{|-7|}{\sqrt{10}} = \frac{7}{\sqrt{10}} = \frac{7\sqrt{10}}{10}.