POV-Ray : Newsgroups : povray.newusers : random elements in blob object : Re: random elements in blob object Server Time
5 Sep 2024 02:16:23 EDT (-0400)
  Re: random elements in blob object  
From: ingo
Date: 2 Feb 2002 03:50:18
Message: <Xns91A9645ADF8A2seed7@povray.org>
in news:01c1abc2$cd6f19a0$667dd383@etnica koos wrote:

> Thanks, for the help. It really works!!

Gaaf he.

> I only don't get the reason why the seed declaration has to be placed
> outside the while-loop. 

#declare S= seed(7) intialises a random stream.
#declare Nr1= rand(S) takes the first random number from the stream.
#declare Nr2= rand(S) takes the second.
#declare Nr3= rand(S) the third.

Note that every time you render your scene Nr1 alway gets the same 
value. Now if you put #declare S= seed(7) inside a loop, it gets 
initialised every time the loop passes it. Thus the value of Nr1 will 
always be the same.
Put the seed outside the loop, it is only initialised once. On the first 
loop we will get the above result. On the second loop:

#declare Nr1= rand(S) takes the fourth random number from the stream.
#declare Nr2= rand(S) takes the fifth.
#declare Nr3= rand(S) the sixth.
etc.

The order of random numbers for a given seed is always the same.

Ingo


Post a reply to this message

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