views:

114

answers:

2

Possible Duplicate:
Shortest distance between a point and a line segment

Hi, I have a point A, and a Line with two endpoint B,C. I want to know how I can calculate the shortest distance between point A and the line formed within B and C. Pseudo-code is enough. Though, Python is preferred. Thanks

A: 

http://stackoverflow.com/questions/849211/shortest-distance-between-a-point-and-a-line-segment

http://mathworld.wolfram.com/Point-LineDistance2-Dimensional.html

Lou Franco
Identify duplicates in the comments.
dmckee
I saw it after I posted the wolfram link and then voted to close based on duplicate.
Lou Franco
+1  A: 

You have to be careful here. Since we are working with the line segment BC, and not a line through the points B and C, the shortest distance from point A to BC is not necessarily perpendicular to BC, as you suggested in your title.

Anyway, check out this post, also on SO, which has python code example and a little discussion of the point above.

David