Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Point on Line Segment in 3D ? Fast Algorithm
Date: Wed, 30 Jun 2010 16:16:21 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 31
Message-ID: <i0fqkl$h2j$1@fred.mathworks.com>
References: <6a9sqqF35gdblU1@mid.uni-berlin.de> <461012205.28470.1277907275265.JavaMail.root@gallium.mathforum.org>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1277914581 17491 172.30.248.37 (30 Jun 2010 16:16:21 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 30 Jun 2010 16:16:21 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: news.mathworks.com comp.soft-sys.matlab:649377

Avni Pllana <avniu66@hotmail.com> wrote in message <461012205.28470.1277907275265.JavaMail.root@gallium.mathforum.org>...
> > Hello,
> > 
> > Im looking for a fast algorithm to determine if a
> > point (3D) is inside a 
> > line segment (3D).
> > Can you help me ?
> > 
> > Regards
> > 
> > Jens
> > 
> > 
> > 
> 
> Hi Jens,
> 
> a simple criterion is as follows:
> 
> norm(P-P1) + norm(P-P2) = norm(P1-P2)
> 
> Best regards,
>     Avni
- - - - - - - - - -
  In the ideal mathematical world, yes, but from a numerical analysis point of view this test is prone to far more inaccuracy than with the cross product.

  Suppose P is at the line segment's midpoint and the segment is of length 2.  If it is moved perpendicularly by .001, Pythagoras's theorem says that the sum of the distances from the endpoints would increase by the much smaller amount 0.000001 .

  Clearly using the sum of the distances this way is a very poor kind of test.

Roger Stafford