POV-Ray : Newsgroups : povray.newusers : Points on line. Server Time
22 Dec 2024 16:07:53 EST (-0500)
  Points on line. (Message 1 to 4 of 4)  
From: kurtz le pirate
Subject: Points on line.
Date: 26 Nov 2011 05:30:39
Message: <kurtzlepirate-DB29A7.11303826112011@news.povray.org>
Hello,

I have a point p1=<x1, y1, z1> and p2=<x2, y2, z2>

I would put N equally spaced points on the 'line' from p1 to p2.

Do you have an idea to do this ?


Thanks

-- 
klp


Post a reply to this message

From: Roman Reiner
Subject: Re: Points on line.
Date: 26 Nov 2011 05:50:00
Message: <web.4ed0c35e6b9045f7c4586f720@news.povray.org>
#local i=0; #while(i<N)
  sphere {
    0, 1
    translate p1+(i/(N-1))*(p2-p1)
  }
#local i=i+1; #end


kurtz le pirate <kur### [at] yahoofr> wrote:
> Hello,
>
> I have a point p1=<x1, y1, z1> and p2=<x2, y2, z2>
>
> I would put N equally spaced points on the 'line' from p1 to p2.
>
> Do you have an idea to do this ?
>
>
> Thanks
>
> --
> klp


Post a reply to this message

From: Warp
Subject: Re: Points on line.
Date: 26 Nov 2011 07:24:42
Message: <4ed0da8a@news.povray.org>
kurtz le pirate <kur### [at] yahoofr> wrote:
> I have a point p1=<x1, y1, z1> and p2=<x2, y2, z2>

> I would put N equally spaced points on the 'line' from p1 to p2.

> Do you have an idea to do this ?

  You have been using POV-Ray too much when...

you wish you had paid more attention in math class instead if thinking that
you would never need that stuff in practice...

  :P

  An answer was already mentioned in another reply, but the explanation is:
You can calculate the weighted average of two points in the exact same way
as you would with to numbers. (If you change the weight linearly, you will
get linearly-placed points between the two endpoints.)

-- 
                                                          - Warp


Post a reply to this message

From: kurtz le pirate
Subject: Re: Points on line.
Date: 27 Nov 2011 01:37:45
Message: <kurtzlepirate-9FD673.07374427112011@news.povray.org>
In article <web.4ed0c35e6b9045f7c4586f720@news.povray.org>,
 "Roman Reiner" <lim### [at] gmxde> wrote:

> #local i=0; #while(i<N)
>   sphere {
>     0, 1
>     translate p1+(i/(N-1))*(p2-p1)
>   }
> #local i=i+1; #end
> 

Thanks Roman, it was really too simple...




-- 
klp


Post a reply to this message

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