POV-Ray : Newsgroups : povray.general : Rand function Server Time
5 Nov 2024 15:51:33 EST (-0500)
  Rand function (Message 1 to 3 of 3)  
From: Steven Jones
Subject: Rand function
Date: 25 Apr 1999 18:23:51
Message: <372387E4.4296BD07@tsn.cc>
Is there any way to make a random seed for the rand function?


Post a reply to this message

From: Margus Ramst
Subject: Re: Rand function
Date: 25 Apr 1999 21:39:27
Message: <3723b5bf.0@news.povray.org>
I'm not sure why you would need it, but you can try this:

#declare S1=seed(1234);
#declare RS1=int(rand(Seed1)*1000);
#declare S2=seed(RS1); //This seed should now be random

If you want it to be random in each frame of an animation, you should
probably do something like this:

#declare RS=int(clock*100);
#declare Seed=seed(RS);

Margus

Steven Jones wrote in message <372387E4.4296BD07@tsn.cc>...
>Is there any way to make a random seed for the rand function?


Post a reply to this message

From: Nieminen Mika
Subject: Re: Rand function
Date: 26 Apr 1999 12:43:19
Message: <37248997.0@news.povray.org>
Margus Ramst <mar### [at] peakeduee> wrote:
: #declare S1=seed(1234);
: #declare RS1=int(rand(Seed1)*1000);
: #declare S2=seed(RS1); //This seed should now be random

  Nope. S2 is exactly as random as S1 (ie. it will always have the same
value). I think that what he meant is a random value which changes from
run to run (like srand(time()) in C).
  AFAIK there's no way to achieve this directly with povray.
  Perhaps one solution is to make a small program which writes the current
time in seconds to a file and then reading that value with the #read function
in povray.

-- 
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):5;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

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