Sign in to follow this  
Aiea

Triangle problem

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.]

Share this post


Link to post
Share on other sites
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!]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this