4

I have two points $P_1(x_1, y_1, z_1)$ and $P_2(x_2, y_2, z_2)$ on a line, $L$, and another point $P_0(x_0, y_0, z_0)$.

I want to find the distance between $P_0$ and $L$. Could someone help?

Thomas
  • 43,555
nkint
  • 1,823
  • 6
  • why at (9) there is only x? what about y and z? – nkint Dec 22 '10 at 14:31
  • 1
    $\mathbf{x}$ is a vector, it has all three components. – Ross Millikan Dec 22 '10 at 14:37
  • and | x_2 - x_1 | is vector magnitude or absolute value? – nkint Dec 22 '10 at 14:54
  • 2
    Vector magnitude. – Raskolnikov Dec 22 '10 at 15:14
  • It is

    $$\begin{eqnarray}\left\vert \mathbf{x}{2}-\mathbf{x}{1}\right\vert &=&\left\vert (x_{2},y_{2},z_{2})-(x_{1},y_{1},z_{1})\right\vert\ &=&\left\vert (x_{2}-x_{1},y_{2}-y_{1},z_{2}-z_{1})\right\vert \ &=&\sqrt{\left(x_{2}-x_{1}\right) ^{2}+\left( y_{2}-y_{1}\right)^{2}+\left( z_{2}-z_{1}\right) ^{2}}\end{eqnarray}$$

    – Américo Tavares Dec 22 '10 at 15:33
  • Do you know what dot and cross products of two vectors are? Otherwise the deduction of the distance formula is more difficult. Perhaps you want to look first to the 2D case. Here http://softsurfer.com/Archive/algorithm_0102/algorithm_0102.htm you find the distance formula between a point $P$ and a line $L$ that passes through the points $P_{0}$ and $P_{1}$: $d(P,L)=\dfrac{\left\vert \mathbf{v}{L}\times \mathbf{w}\right\vert }{\left\vert \mathbf{v}{L}\right\vert }$, with $\mathbf{v}{L}=(P{1}-P_{0})$, $\mathbf{w}=(P-P_{0})$. – Américo Tavares Dec 22 '10 at 16:03
  • :) thank you very much! all clear now! – nkint Dec 23 '10 at 10:16
  • now i'm studing the prove of this because i like it. i think the softsurfer.com/Archive/algorithm_0102/algorithm_0102.htm is really more clear than the profe in wolfram, even if is geometrical and not algebric. Why they use the derivate of distance to minimize it? And why they use that formula for the square distance? – nkint Jan 11 '11 at 20:30
  • "Why they use the derivate of distance to minimize it?" - because finding the optima of a function is equivalent to finding where the derivative of a function becomes zero. – J. M. ain't a mathematician Aug 25 '11 at 04:06
  • I suppose somebody should be posting an answer to this question so that it is settled; who'll do the honors? – J. M. ain't a mathematician Aug 25 '11 at 04:07

3 Answers3

1

The distance $h$ from the point $P_0=(x_0,y_0,z_0)$ to the line passing through $P_1=(x_1,y_1,z_1)$ and $P_2=(x_2,y_2,z_2)$ is given by $h=2A/r$, where $A$ is the area of a triangle defined by the three points and $r$ is the distance from $P_1$ to $P_2$. The values of $r$ and $A$ can be computed as follows:

$r=\sqrt{(x_2-x_1)^2+(y_2-y_1)^2+(z_2-z_1)^2}$ and $A=\frac{1}{2}\sqrt{a_1^2+a_2^2+a_3^2},$

where

$a_1=x_0y_1+x_1y_2+x_2y_0 - (y_0x_1+y_1x_2+y_2x_0),\\ a_2=y_0z_1+y_1z_2+y_2z_0 - (z_0y_1+z_1y_2+z_2y_0),\\ a_3=x_0z_1+x_1z_2+x_2z_0 - (z_0x_1+z_1x_2+z_2x_0).$

Andrey Sokolov
  • 1,536
  • 10
  • 15
1

I thought to furnish a picture:

enter image description here

1

The shortest distance from a point to a line is always perpendicular to the given line. Here, the given line is in the direction of the vector $\langle x_2-x_1, y_2-y_1, z_2-z_1\rangle$. The plane $(x_2- x_1)(x- x_0)+ (y_2- y_1)(y- y_0)+ (z_2- z_1)(z- z_0)= 0$ has that vector as normal vector and contains the point $(x_0, y_0, z_0)$ so the shortest distance is through that plane. Determine where the given line intersects that plane. The shortest distance is the distance form that point of intersection to $(x_0, y_0, z_0)$.

matt
  • 1,419