Calculate distance from point P to line and find the point Q closes to P

1.9k Views Asked by At

I have no idea how to even approach this, I am guessing it has something to do with cross/dot product but I am not sure. Any guidance would be appreciated.

question

2

There are 2 best solutions below

4
On BEST ANSWER

The line passing from the nearest point to $P$ of the line and $P$ is perpendicular to the line. Thus, the inner product of vector line $(3,-1,2)$ and the line passing from $P$ and the closest point is equal to $0$, in other words:

$((x,y,z)-(2,3,-1))\cdot(3,-1,-2)=0$

$\to (3t+2-2,-t+1-3,-2t+3+1) \cdot (3,-1,-2)=0$

$\to (9t)+(t+2)+(4t-8)=0 \to 14t-6=0 \to t=3/7$

Now by substituting $t$ in the line equation you can find the nearest point ($P_n$) and also calculate $d$ by: $d=\sqrt{(x_n-x_p)^2 + (y_n-y_p)^2 + (z_n-z_p)^2}$

2
On

Here are two completely different approaches to the problem, one using vector techniques and one using elementary algebra.

Solution 1

This answer assumes you understand dot products, and know how to find the projection of one vector $\vec{v}$ onto another vector $\vec{w}$ using the formula $$proj_{\vec{w}}\vec{v} = \frac{\vec{v}\cdot \vec{w}}{|\vec{w}|^2}\vec{w}$$

  1. Start by finding a point $A$ on the given line. Any point will do.
  2. Now find the coordinates of the vector $\vec{AP}$. This vector points from the given line to the other point.
  3. Next find the direction vector $\vec{v}$ for the line.

See the diagram below for what we have so far. enter image description here

  1. Now, project $\vec{AP}$ onto the direction vector $\vec{v}$. This gives you the vector shown in red below.

enter image description here 5. Finally, the distance you want is the length of the vector $\vec{AP} - proj_{\vec{v}}\vec{AP}$, labeled $u$ and shown in blue below, and the point you are looking for is the endpoint of the projection vector, marked $C$ in the diagram. enter image description here

Solution 2

Every point on the line has coordinates given by $(2+3t, 1-t, 3-2t)$, for some value of $t$. The distance of such a point from $P$ is given by the distance formula: $$dist = \sqrt{(2+3t-3)^2+(1-t-2)^2+(3-2t+1)^2}$$

You want to find the value of $t$ that makes the distance as small as possible. Now notice that the value of $t$ that minimizes $dist$ will also minimize $dist^2$, so it is enough to find the minimum of $$f(t) = (2+3t-3)^2+(1-t-2)^2+(3-2t+1)^2$$ Simplify this; it's a quadratic function whose graph is a parabola that opens upwards. If you can find the coordinates of the vertex, you can use the $t$ value to find the point on the line that is closest to $P$; the value of $f(t)$ at that location is the square of the distance.