POV-Ray : Newsgroups : povray.general : Math r dumb-Ken r toopid : Re: Math r dumb-Ken r toopid Server Time
12 Aug 2024 11:25:08 EDT (-0400)
  Re: Math r dumb-Ken r toopid  
From: Jerry Anning
Date: 19 Feb 1999 14:50:15
Message: <36cdbe96.16933852@news.povray.org>
On Fri, 19 Feb 1999 10:26:56 -0800, Ken <tyl### [at] pacbellnet> wrote:


> Is it possible to trap a specific number generated by the rand
>function to be used in another portion of a loop ?
>
>  An example of why I ask would be to create non umiform scaled wood
>shingles for a roof. They are usually the same in thichkess and length
>but the width varies. I could use the rand function within a loop to
>vary the scale of each oject generated but it would greatly complicate
>the position of the shingles as they are translated into postion through
>the loop count. My idea of a solution would be know what variation of
>scaling is given by the rand function for each object and using that
>value to adjust the translated position of the objects accordingly.
> Is it possible to do something like this and if so how, what, when,
>where, and why ?

Just generate the random number separately, save it in a variable, and
use it in both places.  For your shingling project, in order to
account for the variable positions of other shingles, you could either
save the random numbers in an array as you create them and sum the
correct row or column for the needed offset, or (bad idea) reset the
random number stream with the original seed and run the random number
through the needed number of iterations at placement time.  If you are
crazy enough to do that, you will also have to reseed and iterate each
time in the placement loop.  An array would be much better.

Jerry Anning
clem "at" dhol "dot" com


Post a reply to this message

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