POV-Ray : Newsgroups : povray.advanced-users : rand help : Re: rand help Server Time
29 Jul 2024 22:26:51 EDT (-0400)
  Re: rand help  
From: Jan Walzer
Date: 3 Dec 2000 16:03:23
Message: <3a2ab51b@news.povray.org>
st you need to declare a "silly variable" (Yes I know it's not
silly) to reference to your random generator ...
I often do a
#declare sd=seed(42);

Note: you can choose the number you want here ... If you have the
same number here, the random numbers you get will always be in
the same order, so your randomness is always the same through
different renders...

The when you want a randomnumber make:

#declare x=rand(sd);

This will give you an x: 0<x<1 ... (maybe 0 is also available)

if you want other numbers then you need to scale the interval...
let's say: You want the numbers from -5 to +5 ...
is interval has a size of 10 and starts at -5, so we write:
#declare x=(rand(sd)*10)-5;

so in your case this would mean you have to write:
#declare MyRandomNumber=rand(sd)*.25+0.75;

Hope it helps ...
CU Jan

--

 ,',    Jan Walzer      \V/  http://wa.lzer.net     ,',
',','   student of      >|<  mailto:jan### [at] lzernet ',','
  '   ComputerScience   /A\  +49-177-7403863         '

Laurence M. Salme <lsa### [at] rciacom> schrieb in im Newsbeitrag:
3A2AA54B.72E0F206@rcia.com...
> I need help understanding how to use rand and seed. I figure a
random of
> .75 to 1.0
> may be needed for an image i'm working on. Any good tutorials
out there
> or examples of generating narrow ranges of random numbers. Any
help
> would be greatly
> appreciated.
>


Post a reply to this message

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