Triangle problem

Started by
5 comments, last by Aiea 15 years, 8 months ago
Hi people, I have a linear line and a point and I found the shortest distance between them. So my question is, how do I find the point on the linear line where the shortest distance line is? Mahalo, Aiea
Mahalo,AieaLove them semicolons and equal signs...
Advertisement
If your line goes from point A to point B, and the third point floating in space is point C, then you can use the projection formula to find the closest point on the line, D:

D = (B - A) * ([(B - A).(C - A)] / [(B - A).(B - A)]) + A

Then the shortest distance is |D - C|. So it's actually easier to find the point first and then the distance :) Note that this assumes the line is infinite is both directions. If the line is finite, then calculate this quantity:

(D - A).(B - A)

If it's greater than (B - A).(B - A), then the closest point is actually B, and if it's less than 0, the closest point is actually A.
Ok so on my line I just mark arbitrary points and plug in that formula to find out the shortest distance from a point on the line to my known point correct?

When you say B - A and stuffs like that, how would I subtract them from each other when they are just points? Also what does your . mean between the parenthesis?
Mahalo,AieaLove them semicolons and equal signs...
This is called projection.

If your line is defined by a point p and a vector v; i.e., your line is the set of all points x satisfying,

x = p + v t

for some t in (-infinity, infinity), and your other point is z, then the point w on the line closest to z is given by,

w = p + ( v / ||v|| )[ (z - p) dot v ]

In fancy language, your line is an affine variety (a line/plane/hyperplane, in geometric terms). When you translate everything to the origin (i.e., subtract p), it becomes a linear variety or linear subspace (a line/plane/hyperplane passing through the origin). Then you project onto the subspace using a dot product, and, finally, you translate the result back into your original space (i.e., add p).

[EDIT: Looks like Zipster beat me to it. Also, Aiea, it sounds like you could use an introduction to vector math. I'm currently googling, looking for an introduction that will approach the subject from a linear algebra point of view (instead of from a trigonometry point of view) since I think that's easier in the long run.]
To add/subtract two points/vectors, you add/subtract each component individually. Also, '.' means the dot product. Take a look here.
Here we go! It took me a while to find a good introduction to the subject, but I think this page will do the trick nicely:

http://em-ntserver.unl.edu/Math/mathweb/vectors/vectors.html

Read this page through from the beginning and I expect that all your questions will be answered, Aiea!

[EDIT: Again, Zipster beat me to it!]
Thanks guys, I'll make sure to read them.

Mahalo
Mahalo,AieaLove them semicolons and equal signs...

This topic is closed to new replies.

Advertisement