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


"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
> 
Roger,

This fromual needs that the point be specified for the z 
axis. 

Do you use z= 0 or z =1?

Chuk