Shortest distance between a point and a line segment
Posted
by Eli Courtwright
on Stack Overflow
See other posts from Stack Overflow
or by Eli Courtwright
Published on 2009-05-11T17:47:52Z
Indexed on
2010/04/25
10:03 UTC
Read the original article
Hit count: 301
geometry
|language-agnostic
I need a basic function to find the shortest distance between a point and a line segment. Feel free to write the solution in any language you want; I can translate it into what I'm using (Javascript).
EDIT: My line segment is defined by two endpoints. So my line segment AB is defined by the two points A (x1,y1) and B (x2,y2). I'm trying to find the distance between this line segment and a point C (x3,y3). My geometry skills are rusty, so the examples I've seen are confusing, I'm sorry to admit.
© Stack Overflow or respective owner