POV-Ray : Newsgroups : povray.windows : Using calls to rand() : Re: Using calls to rand() Server Time
28 Jul 2024 12:35:37 EDT (-0400)
  Re: Using calls to rand()  
From: David Wilkinson
Date: 28 Feb 1999 10:45:22
Message: <36da63f5.19064621@news.povray.org>
On 28 Feb 1999 09:14:52 -0500, Jeremy Botha (jer### [at] rucusruacza)
wrote:

>Hi - I'm trying to create a "space" scene containing (obviously) stars.  What I am
trying to do is to set up all the individual stars using calls to rand() Eg: sphere {
<rand(r1),80,rand(r2)>, 0.1 } where r1 and r2 are two different seeded values. 
Unfortunately, Pov-ray isn't being very cooperative, and I don't know any formulas
offhand which can give me a nice random starfield between x:(-8;26) and z(-18;2), y
probably constant at 80.  If anyone could mail me any hints or fragments of code to
try out, I wwould be much obliged.  If this is the wrong place to post this, please
tell me and I'll post it somewhere else :-) Jeremy

Jeremy all you have to do is to scale your rand functions to suit your
field size.  The following code illustrates.
Your post would have probably been better in povray.general (and my
response should have been in povray.text.scene-files) but not to worry
:-)
David

#include "colors.inc"

camera
{
  location  <9, 105, -8>
  look_at   <9, 0.0, -8>
}
 
light_source
{
  <-2,300,-20>
  rgb 1
}
 #declare R1 = seed(89);
 #declare R2 = seed(231);

 #declare Count=0;
 #while (Count < 200)
    sphere { <34*rand(R1)-8,80,20*rand(R2)-18>, 0.1 pigment {White}}
  #declare Count=Count+1;
 #end

------------
dav### [at] cwcomnet
http://www.hamiltonite.mcmail.com
------------


Post a reply to this message

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