POV-Ray : Newsgroups : povray.newusers : Need rand() help : Re: Need rand() help Server Time
29 Jul 2024 02:33:12 EDT (-0400)
  Re: Need rand() help  
From: Slime
Date: 8 Jan 2007 23:37:52
Message: <45a31c20$1@news.povray.org>
> Thanks for the fast reply.  Is the value plugged into the rand() statement
> actually a subscript to a value in the random number stream?  If yes, then
> how long is the random number stream (how many times can I tap into the
same
> stream)? TIA, again...gjw


Think of colorSeed as a list of random numbers, and rand(colorSeed) always
gets the next one. If you want to start over, you just #declare colorSeed
again in the same way. My guess is that the stream is about 2^32 numbers
long, which is long enough that you'll never hit the end of it (and if you
do it will just loop back to the beginning).

The only reason to have the "seed" in the first place is so that you can
have different streams of random numbers. So if you write code that
generates 100 random colors, and you like the randomness you're getting, but
in the same loop you want to generate 100 random positions, you can use a
different seed (like positionSeed or something) and it won't change the
colors that are generated.

 - Slime
 [ http://www.slimeland.com/ ]


Post a reply to this message

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