POV-Ray : Newsgroups : povray.newusers : Random Numbers Server Time
5 Nov 2024 11:19:38 EST (-0500)
  Random Numbers (Message 1 to 6 of 6)  
From: Matthew Pace
Subject: Random Numbers
Date: 30 Oct 2003 17:43:25
Message: <matt-pace-BC88DB.14432430102003@netplex.aussie.org>
Hello again,
Can someone please explain how to get POVRAY to produce random numbers?  
I checked the Docs, and i was confused by them.  I have not heard of 
output streams in POV, so if anyone can clarify, that would be wonderful.

Thanks in advance,
Matt


Post a reply to this message

From: Warp
Subject: Re: Random Numbers
Date: 30 Oct 2003 19:25:23
Message: <3fa1abf3@news.povray.org>
Matthew Pace <mat### [at] lycoscom> wrote:
> Can someone please explain how to get POVRAY to produce random numbers?  
> I checked the Docs, and i was confused by them.  I have not heard of 
> output streams in POV, so if anyone can clarify, that would be wonderful.

  Have you tried what the docs suggested?

  Anyways, here's an example which should get you started:

camera { location <0,6,-6> look_at 0 angle 35 }
light_source { <100,200,-50>, 1 }

#declare Seed = seed(0); // Note *where* I initialize the seed

#declare Ind = 0;
#while(Ind < 200) // 200 spheres
  // rand(Seed) returns a value between 0 and 1
  #declare RandomLocation = <rand(Seed)*4-2, 0, rand(Seed)*4-2>;
  #declare RandomColor = <rand(Seed), rand(Seed), rand(Seed)>;

  sphere { RandomLocation, .05 pigment { rgb RandomColor } }

  #declare Ind = Ind+1;
#end

plane { y, -.05 pigment { checker rgb 1, rgb .5 } }


-- 
plane{-x+y,-1pigment{bozo color_map{[0rgb x][1rgb x+y]}turbulence 1}}
sphere{0,2pigment{rgbt 1}interior{media{emission 1density{spherical
density_map{[0rgb 0][.5rgb<1,.5>][1rgb 1]}turbulence.9}}}scale
<1,1,3>hollow}text{ttf"timrom""Warp".1,0translate<-1,-.1,2>}//  - Warp -


Post a reply to this message

From: Matthew Pace
Subject: Re: Random Numbers
Date: 30 Oct 2003 20:34:56
Message: <matt-pace-244464.17345630102003@netplex.aussie.org>
Ok, perfect.  Thanks a lot, that sums up all I needed to know.  One last 
question though, is there a way to seed the file with a time based 
variable, like in programming?

Thanks a lot


Post a reply to this message

From: Brent G
Subject: Re: Random Numbers
Date: 30 Oct 2003 20:43:57
Message: <3fa1be5d@news.povray.org>
Matthew Pace wrote:
> Ok, perfect.  Thanks a lot, that sums up all I needed to know.  One last 
> question though, is there a way to seed the file with a time based 
> variable, like in programming?
> 
> Thanks a lot

AFAIK, unless you're doing an animation, no.


Post a reply to this message

From: Christopher James Huff
Subject: Re: Random Numbers
Date: 30 Oct 2003 20:45:28
Message: <cjameshuff-127AE2.20433430102003@netplex.aussie.org>
In article <mat### [at] netplexaussieorg>,
 Matthew Pace <mat### [at] lycoscom> wrote:

> Ok, perfect.  Thanks a lot, that sums up all I needed to know.  One last 
> question though, is there a way to seed the file with a time based 
> variable, like in programming?

You can save seeds to a file. Seed your streams from that file and write 
new seeds. Unfortunately, there's nothing like a date function in the 
official version that can be used to seed the random number streams.

However, you most likely just want to output a large number of 
variations of something. In this case, you would probably be best off 
using frame_number to create the seed and rendering an animation. This 
way, you get the same numbers each time, making debugging and tweaking 
easier, but you also get a large number of seeds. If you want a 
different set of seeds, change the method you use to create the seed 
from frame_number.

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: chr### [at] tagpovrayorg
http://tag.povray.org/


Post a reply to this message

From: Mike Williams
Subject: Re: Random Numbers
Date: 31 Oct 2003 00:07:04
Message: <eQRP4FAkzeo$EwG4@econym.demon.co.uk>
Wasn't it Matthew Pace who wrote:
>Ok, perfect.  Thanks a lot, that sums up all I needed to know.  One last 
>question though, is there a way to seed the file with a time based 
>variable, like in programming?

There's a facility for doing this in earlier versions of MegaPOV, but it
didn't make it into MegaPOV 1.0 when it was rewritten based on the POV
3.5 source instead of the 3.1 source.

   "MegaPOV 1.0 is a fresh start, based on the sources of POV-Ray 3.5. 
   This means that not all features of MegaPOV 0.7 are implemented yet."

If you don't need to use any 3.5 features, then you can use MegaPOV 0.7,
or go looking to see if the feature made it into any other patches. The
syntax is

   #declare Seed = seed(tick_count);

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

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