POV-Ray : Newsgroups : povray.newusers : Using rand(); clear howto! : Re: Using rand(); clear howto! Server Time
5 Sep 2024 08:19:17 EDT (-0400)
  Re: Using rand(); clear howto!  
From: Warp
Date: 11 May 2001 12:47:00
Message: <3afc1784@news.povray.org>
Simon Lemieux <lem### [at] yahoocom> wrote:
: That's the reason why I prefered C++, but now that I
: understand how it works, I realized I was just dumb!

  I think that most of us have made this kind of mistakes (or even worse)
many times with POV-Ray, so don't feel too dumb :)

  What I really like about POV-Ray's random numbers is the fact that you
can have several random number generators. This is usually quite difficult
with C++ or other programming languages (unless you make your own random
number implementation).
  For example, suppose that you have made a little code that positions
objects randomly in a loop and you search for an initial seed value which
gives a nice distribution of the objects.
  After this you get the idea that it would be nice if the objects were
also colored randomly.
  Oops! If you set the color of the objects randomly using the same generator
as is used to calculate the location of the objects, the locations will
be messed up and you will loose your nice distribution.
  But no worries: Just use a different random number generator (even with
the same initial seed value if you want) to color the objects. This way their
location will be unchanged.
  Nice.

-- 
#macro N(D,I)#if(I<6)cylinder{M()#local D[I]=div(D[I],104);M().5,2pigment{
rgb M()}}N(D,(D[I]>99?I:I+1))#end#end#macro M()<mod(D[I],13)-6,mod(div(D[I
],13),8)-3,10>#end blob{N(array[6]{11117333955,
7382340,3358,3900569407,970,4254934330},0)}//                     - Warp -


Post a reply to this message

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