POV-Ray : Newsgroups : povray.advanced-users : Distance to line segment? : Re: Distance to line segment? Server Time
26 Sep 2024 17:44:05 EDT (-0400)
  Re: Distance to line segment?  
From: Ron Parker
Date: 23 Dec 2000 23:33:14
Message: <slrn94av4e.53d.ron.parker@fwi.com>
On Fri, 22 Dec 2000 23:53:52 +0100, Tor Olav Kristensen wrote:
>
>Ron Parker wrote:
>> 
>> On Thu, 21 Dec 2000 22:23:23 +0100, Rune wrote:
>> >How do I find the distance from the point P to the nearest point in the line
>> >segment defined by point A and point B?
>> 
>> The distance to the line defined by A and B is given by
>> 
>> P-A-vdot(P-A,B-A)/vlength(B-A)
>
>It seems like you are subtracting 
>a scalar from a vector expression.
>
>Are you that this is the right thing 
>to do here ?

Nope.  That's what I get for posting without testing.  The scalar should be
multiplied by the unit vector in the direction of B-A, or by (B-A)/vlength(B-A).


-- 
Ron Parker   http://www2.fwi.com/~parkerr/traces.html
My opinions.  Mine.  Not anyone else's.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.