POV-Ray : Newsgroups : povray.windows : Using calls to rand() Server Time
28 Jul 2024 14:24:10 EDT (-0400)
  Using calls to rand() (Message 1 to 3 of 3)  
From: Jeremy
Subject: Using calls to rand()
Date: 28 Feb 1999 09:14:52
Message: <36d94f5c.0@news.povray.org>
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


Post a reply to this message

From: David Wilkinson
Subject: Re: Using calls to rand()
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

From: bassompierre laurent
Subject: Re: Using calls to rand()
Date: 1 Mar 1999 04:18:28
Message: <36da5b64.0@news.povray.org>
Some code to help you. Parsing time can be long if use a large number of
stars !!


>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
>


Post a reply to this message


Attachments:
Download 'stars.pov.txt' (2 KB)

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