POV-Ray : Newsgroups : povray.general : Point along a line. : Re: Point along a line. Server Time
4 Aug 2024 04:19:32 EDT (-0400)
  Re: Point along a line.  
From: Christopher James Huff
Date: 18 Jul 2003 19:31:38
Message: <cjameshuff-53B49B.18254818072003@netplex.aussie.org>
In article <web.3f187c7a5afdf36ca6ac136d0@news.povray.org>,
 "BorisW37" <Bor### [at] yahoocom> wrote:

> If i have 2 points A <x1,y1,z1> and B <x2,y2,z2>, how do i find coordinates
> of point C <x3,y3,z3> which lies on the line AB, distance D from point A?

vnormalize(B - A)*D + A

Find a vector pointing in the direction of the line (B-A), normalize it 
so its length is 1, scale it by the desired distance, and add it to the 
first point of the line. If you leave out the vnormalize(), D acts as 
the percentage (as a fractional value in the range [0, 1]) of the 
distance from A to B, rather than the absolute distance in units.

Or if you are just looking for the midpoint, (A + B)/2 will work.

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: chr### [at] tagpovrayorg
http://tag.povray.org/


Post a reply to this message

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