[Math] calculating perpendicular and angular distance between line segments in 3d

3dgeometry

I originally posted this over at stackoverflow and they suggested asking it over here.

link to original: https://stackoverflow.com/questions/5222781/calculating-perpendicular-and-angular-distance-between-line-segments-in-3d

Text of original:

I am working on implementing a clustering algorithm in C++. Specifically, this algorithm: http://www.cs.uiuc.edu/~hanj/pdf/sigmod07_jglee.pdf

At one point in the algorithm (sec 3.2 p4-5), I am to calculate perpendicular and angular distance (d┴ and dθ) between two line segments: $p_1$ to $p_2$, $p_1$ to $p_3$.

It has been a while since I had a math class, I am kinda shaky on what these actually are conceptually and how to calculate them. Can anyone help?


It looks like I can calculate the perpendicular distance by the following $\left(\frac{d_1^3 + d_2^3}{d1^2 + d2^2}\right)$, where d1 is the euclidean distance between the starting points and d2 is the euclidean distance between the ending points. How would I calculate euclidean distances though?

The angular distance looks to be calculated by the dot product of the vectors. It has been about $10$ years since linear algebra so I am very rusty on this but I think I can get a handle on this one hopefully. Just a bit unsure of how to conceptually transfer line segments to vectors.

Anyway, any help you all could offer would be greatly appreciated.

Best Answer

How are you defining the distance between two segments? It appears the two segments share an endpoint, so the distance would normally be zero. Then if you take the two vectors $\vec {v_1}= \overrightarrow{p_2-p_1}$ and $\vec {v_2}= \overrightarrow{p_3-p_1}$, you have $\cos(\theta)=\frac{\vec {v_1}\cdot \vec {v_2}}{|\vec {v_1}||\vec {v_2}|}$ where $\theta$ is the angle between them.

Related Question