Shortest distance between two line segments
Posted
by Frank
on Stack Overflow
See other posts from Stack Overflow
or by Frank
Published on 2010-05-13T04:49:44Z
Indexed on
2010/05/13
4:54 UTC
Read the original article
Hit count: 234
geometry
|language-agnostic
I need a function to find the shortest distance between two line segments. A line segment is defined by two endpoints. So for example one of my line segments (AB) would be defined by the two points A (x1,y1) and B (x2,y2) and the other (CD) would be defined by the two points C (x1,y1) and D (x2,y2).
Feel free to write the solution in any language you want and I can translate it into javascript. Please keep in mind my geometry skills are pretty rusty. I have already seen http://stochastix.wordpress.com/2008/12/28/distance-between-two-lines/ and I am not sure how to translate this into a function. Thank you so much for help.
© Stack Overflow or respective owner