0:00 / 0:00

Distance From a Point to a Line in R3

Suppose that r=r0+tm\vec{r}=\vec{r_0}+t\vec{m} is a line in R3R^3and Q(x0, y0)Q(x_0,\ y_0)is a point on this line.

The shortest distance between a point P(x1,  y1)P\left(x_1,\ \ y_1\right) and this line is d=QP×mm\displaystyle d=\frac{\left|\left|\overrightarrow{QP}\times\vec{m}\right|\right|}{\left|\left|\vec{m}\right|\right|} or d=QPsinθd=||\overrightarrow{QP}||\sin\theta.

Example
Find the shortest distance between the point (1, 0, 1)\left(1,\ 0,\ -1\right) annd the line r=[1, 1, 2]+t[0, 1, 1]\vec{r}=\left[1,\ 1,\ 2\right]+t\left[0,\ -1,\ -1\right]

A point on the line is Q=(1,1,2)Q=(1,1,2), the point we are given is P(1,0,1)P(1,0,-1)
QP=[1,0,1][1,1,2]=[0,1,3]\overrightarrow{QP}=[1,0,-1]-[1,1,2]=[0,-1,-3]

The direction vector is m=[0,1,1]\vec m=[0,-1,-1].

Using the formula:
d=[0,1,3]×[0,1,1][0,1,1]\displaystyle d=\frac{\left|\left|\left[0,-1,-3\right]\times\left[0,-1,-1\right]\right|\right|}{\left|\left|\left[0,-1,-1\right]\right|\right|}

d=[2, 0, 0]02+(1)2+(1)2\displaystyle d=\frac{\left|\left|\left[-2,\ 0,\ 0\right]\right|\right|}{\left|\left|\sqrt{0^2+\left(-1\right)^2+\left(-1\right)^2}\right|\right|}

d=22+02+022\displaystyle d=\frac{\sqrt{2^2+0^2+0^2}}{\sqrt{2}}

d=22\displaystyle d=\frac{2}{\sqrt{2}}

d=22×22\displaystyle d=\frac{2}{\sqrt{2}}\times\frac{\sqrt{2}}{\sqrt{2}}

d=222\displaystyle d=\frac{2\sqrt{2}}{2}

d=2d=\sqrt{2}

Practice: Distance Between 2 Parallel Lines in R3

Find the shortest distance between the lines r1=[1,1,0]+t[3,1,3]\vec {r_1}=[1, 1, 0]+t[3, 1, 3] and r2=[1,1,2]+s[3,1,3]\vec {r_2}=[-1, 1, 2]+s[3, 1, 3].
0:00 / 0:00

Example: Closest Point on a Line

a) Find the coordinates of the point on the line r=[1,0,1]+t[1,1,1]\vec{r}=[1,0,-1]+t[-1,1,-1] that is closest to the point P(0,2,1)P(0, 2, 1).
b) Find the shortest distance between the point P(0,2,1)P\left(0,2,1\right) and the line.

a) Let Q(x0,y0,z0)Q(x_0, y_0,z_0) be the point on the line that is closest to PP.

First, let's rewrite the line into parametric form:
x=1ty=tz=1t\begin{array}{l} x=1-t\\y=t\\z=-1-t \end{array}
So, QQ is of the form (1t,t,1t)(1-t, t, -1-t) for some value of tRt\in R.

We know that the position vector QP\overrightarrow{QP} is perpendicular to the line:
The position vector is QP=[0,2,1][1t,t,1t]=[1+t,2t,2+t]\overrightarrow{QP}=[0,2,1]-[1-t,t,-1-t]=[-1+t,2-t,2+t]

Since this is perpendicular to the line, the dot product between this position vector and the line's direction vector should be 0:
QPm=0\overrightarrow{QP}\cdot \overrightarrow{m}=0
[1+t,2t,2+t][1,1,1]=0[-1+t,2-t,2+t]\cdot[-1,1,-1]=0
1t+2t2t=01-t+2-t-2-t=0
13t=01-3t=0
t=13t=\frac{1}{3}

Therefore, the point on the line closest to the point P is (113, 13, 113)\left(1-\frac{1}{3},\ \frac{1}{3},\ -1-\frac{1}{3}\right), which is (23, 13, 43)\left(\frac{2}{3},\ \frac{1}{3},\ -\frac{4}{3}\right)

b) The shortest distance is QP\left|\left|\overrightarrow{QP}\right|\right|
QP=[0,2,1][23, 13, 43]=[23, 53, 73]\overrightarrow{QP}=\left[0,2,1\right]-\left[\frac{2}{3},\ \frac{1}{3},\ -\frac{4}{3}\right]=\left[-\frac{2}{3},\ \frac{5}{3},\ \frac{7}{3}\right]
QP=(23)2+(53)2+(73)2=4+25+499=263\left|\left|QP\right|\right|=\sqrt{\left(-\frac{2}{3}\right)^2+\left(\frac{5}{3}\right)^2+\left(\frac{7}{3}\right)^2}=\sqrt{\frac{4+25+49}{9}}=\sqrt{\frac{26}{3}}

Practice: Reflection of a Point

Find the coordinates of the point obtained by reflecting the point P(1, 2, 3)P\left(1,\ 2,\ -3\right) along the line r=[0, 1, 0]+t[1,0, 1]\vec{r}=\left[0,\ 1,\ 0\right]+t\left[1,0,\ -1\right].