Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: distance between point and line segment
Date: Sat, 29 Mar 2008 15:31:01 +0000 (UTC)
Organization: AGCO
Lines: 32
Message-ID: <fslnbl$go5$1@fred.mathworks.com>
References: <4a2f4ac1-c21e-4ebf-8530-352f15098a47@41g2000hsc.googlegroups.com> <fpdqru$8lg$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1206804661 17157 172.30.248.37 (29 Mar 2008 15:31:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sat, 29 Mar 2008 15:31:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1073303
Xref: news.mathworks.com comp.soft-sys.matlab:459816


"Roger Stafford" 
<ellieandrogerxyzzy@mindspring.com.invalid> wrote in 
message <fpdqru$8lg$1@fred.mathworks.com>...
> Steve <srjm72499@gmail.com> wrote in message <4a2f4ac1-
> c21e-4ebf-8530-
352f15098a47@41g2000hsc.googlegroups.com>...
> > Is there a simple way to find the distance between a 
line segment and
> > a point?  I'm looking for the 2D case specifically, 
but the more
> > general 3D case would also be nice to know...
> > Thanks.
> > -Steve
> -------
>   Let Q1 and Q2 be endpoints (or any two distinct 
points) of the line segment 
> and P the point in question, then
> 
>  d = abs(cross(Q2-Q1,P-Q1))/abs(Q2-Q1);
> 
> will give the requested orthogonal distance.
> 
> Roger Stafford
> Also is there a simple way to know if the distances are 
on the same side or oposite sides of the line?

Thanks for your help

Chuk