# Triangle problem

This topic is 3711 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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 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 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 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 on other sites
To add/subtract two points/vectors, you add/subtract each component individually. Also, '.' means the dot product. Take a look here.

##### 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 on other sites
Thanks guys, I'll make sure to read them.

Mahalo

1. 1
2. 2
Rutin
25
3. 3
4. 4
5. 5

• 10
• 13
• 19
• 14
• 9
• ### Forum Statistics

• Total Topics
632942
• Total Posts
3009343
• ### Who's Online (See full list)

There are no registered users currently online

×