POV-Ray : Newsgroups : povray.general : other random function : other random function Server Time
31 Jul 2024 08:20:19 EDT (-0400)
  other random function  
From: stevenvh
Date: 6 Aug 2007 13:50:00
Message: <web.46b75deb83bdbb18e99dba500@news.povray.org>
rand() returns a value in [0..1[, which is as general as it gets, but I
often need a random value in [A-B..A+B].
Of course I could write

    #declare myvar = A + B * ( 2 * rand(rnd) - 1 );

but I would love to have a function, say rand2(), which I could use as e.g.

    #declare myvar = rand2(rnd, A, B);

or even

    sphere { < rand2(rnd, A, B), rand2(rnd, A, B), rand2(rnd, A, B) >, 100 }

Is this possible? I gather that I can't use rand() in user-defined
functions.
TIA

Steven


Post a reply to this message

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