POV-Ray : Newsgroups : povray.newusers : rand not producing random! Server Time
24 Nov 2024 07:07:50 EST (-0500)
  rand not producing random! (Message 1 to 10 of 17)  
Goto Latest 10 Messages Next 7 Messages >>>
From: geogeo
Subject: rand not producing random!
Date: 6 Jan 2010 15:45:00
Message: <web.4b44f58178f10047a77823820@news.povray.org>
I am using a rand generated value 'n' but the result is always the same. I've
put in a text trace to output the value 'n' as follows:

#declare R1 = seed(1);
#declare n = rand(R1);

//....//
text {
    ttf "timrom.ttf" str(n,0,3) 0.3, 0
    pigment { Red }
    translate<0,2,0>
  }

With the above seed the result is alwways 0.422. What am I missing here?

geo


Post a reply to this message

From: Stephen
Subject: Re: rand not producing random!
Date: 6 Jan 2010 17:00:05
Message: <4b4507e5$1@news.povray.org>
geogeo wrote:
> I am using a rand generated value 'n' but the result is always the same. I've
> put in a text trace to output the value 'n' as follows:
> 
> #declare R1 = seed(1);
> #declare n = rand(R1);
> 
> //....//
> text {
>     ttf "timrom.ttf" str(n,0,3) 0.3, 0
>     pigment { Red }
>     translate<0,2,0>
>   }
> 
> With the above seed the result is alwways 0.422. What am I missing here?
> 

What you get with rand is a series of random numbers. Using the same 
seed the series is always the same.


-- 

Best Regards,
	Stephen


Post a reply to this message

From: Tim Attwood
Subject: Re: rand not producing random!
Date: 6 Jan 2010 19:30:40
Message: <4b452b30$1@news.povray.org>
> What you get with rand is a series of random numbers. Using the same 
> seed the series is always the same.

That's an intentional design feature, if you place a bunch of objects
randomly with a certain seed, the image should still be exactly
reproducable on any machine running POV. Also, if you are
unhappy with the way a random placement pattern looks, you 
can try another seed until you are happy with the placement, 
and then be able to reproduce that same pattern in a final scene 
with slower features like radiosity and photons turned on.


Post a reply to this message

From: Kenneth
Subject: Re: rand not producing random!
Date: 7 Jan 2010 02:55:00
Message: <web.4b4591e4cc0023fa65f302820@news.povray.org>
"Tim Attwood" <tim### [at] anti-spamcomcastnet> wrote:
> > What you get with rand is a series of random numbers. Using the same
> > seed the series is always the same.
>
> That's an intentional design feature, if you place a bunch of objects
> randomly with a certain seed, the image should still be exactly
> reproducable on any machine running POV.

It's also of great practical use when making an animation--the seed() value,
being the same for every animation frame, produces the same rand() values per
frame.  If it didn't, there would be chaos!

Ken


Post a reply to this message

From: geogeo
Subject: Re: rand not producing random!
Date: 7 Jan 2010 14:10:01
Message: <web.4b463117cc0023fa1daa28400@news.povray.org>
"Kenneth" <kdw### [at] earthlinknet> wrote:
> "Tim Attwood" <tim### [at] anti-spamcomcastnet> wrote:
> > > What you get with rand is a series of random numbers. Using the same
> > > seed the series is always the same.
> >
> > That's an intentional design feature, if you place a bunch of objects
> > randomly with a certain seed, the image should still be exactly
> > reproducable on any machine running POV.
>
> It's also of great practical use when making an animation--the seed() value,
> being the same for every animation frame, produces the same rand() values per
> frame.  If it didn't, there would be chaos!
>
> Ken

Thanks Stephen, Tim, Kenneth for replies - which explains things.

So is there any way at all to produce a randomised number within POV?


Post a reply to this message

From: Warp
Subject: Re: rand not producing random!
Date: 7 Jan 2010 14:19:39
Message: <4b4633cb@news.povray.org>
geogeo <geo### [at] mecolcouk> wrote:
> I am using a rand generated value 'n' but the result is always the same. I've
> put in a text trace to output the value 'n' as follows:

> #declare R1 = seed(1);
> #declare n = rand(R1);

  Well, you specified a seed of 1, and then you pull out a number from the
RNG stream. Of course you are going to get the next number in the stream
created with seed(1). That's by design.

> //....//
> text {
>     ttf "timrom.ttf" str(n,0,3) 0.3, 0
>     pigment { Red }
>     translate<0,2,0>
>   }

  Btw, #debug exists for that exact purpose. Much easier to use.

-- 
                                                          - Warp


Post a reply to this message

From: geogeo
Subject: Re: rand not producing random!
Date: 7 Jan 2010 14:50:00
Message: <web.4b463a95cc0023fa1daa28400@news.povray.org>
Warp <war### [at] tagpovrayorg> wrote:
> geogeo <geo### [at] mecolcouk> wrote:
> > I am using a rand generated value 'n' but the result is always the same. I've
> > put in a text trace to output the value 'n' as follows:
>
> > #declare R1 = seed(1);
> > #declare n = rand(R1);
>
>   Well, you specified a seed of 1, and then you pull out a number from the
> RNG stream. Of course you are going to get the next number in the stream
> created with seed(1). That's by design.
>
> > //....//
> > text {
> >     ttf "timrom.ttf" str(n,0,3) 0.3, 0
> >     pigment { Red }
> >     translate<0,2,0>
> >   }
>
>   Btw, #debug exists for that exact purpose. Much easier to use.
>
> --
>                                                           - Warp

Thanks for info on #debug, had not noticed that feature, only been at this a few
days. But how do I get it to output variables? The following #debug fails:

#declare R1 = seed(1);
#declare n = rand(R1);
#debug "rand out = ",str(n),"\n";

thanks
Geo


Post a reply to this message

From: Warp
Subject: Re: rand not producing random!
Date: 7 Jan 2010 14:54:24
Message: <4b463bf0@news.povray.org>
geogeo <geo### [at] mecolcouk> wrote:
> Thanks for info on #debug, had not noticed that feature, only been at this a few
> days. But how do I get it to output variables? The following #debug fails:

> #declare R1 = seed(1);
> #declare n = rand(R1);
> #debug "rand out = ",str(n),"\n";

  #debug takes one single string as parameter. To build a string made of
several components, you use the concat() function:

#debug concat("rand out = ", str(n, 0, -1), "\n")

-- 
                                                          - Warp


Post a reply to this message

From: Mike Williams
Subject: Re: rand not producing random!
Date: 7 Jan 2010 15:13:32
Message: <KxZQilEYAkRLFwc$@econym.demon.co.uk>
Wasn't it geogeo who wrote:
>
>So is there any way at all to produce a randomised number within POV?

Some versions of MegaPOV had a tick_count variable which returns the 
value of the computer's internal clock variable.

In official versions of POV, one thing you can do is pass an external 
value into the scene with a command line "Declare" and use that value as 
the seed. If you launch POV from a programming language that has access 
to the computer's internal clock variable, you could pass that value 
into the scene that way.

Another approach would be to store the seed in an external file. Read 
the value with fopen and fread, use it as the seed for the current scene 
then change the value (e.g. by adding 1) and write it back. That way, 
the next time you run that scene you get a different seed value. That 
also has the advantage that if you decide that the version of your scene 
that you rendered three iterations ago had a particularly pretty random 
pattern that you'd like to go back to, you can examine the file and work 
out what the seed would have been.

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

From: geogeo
Subject: Re: rand not producing random!
Date: 8 Jan 2010 15:05:00
Message: <web.4b478ee2cc0023fa72e0f8010@news.povray.org>
Warp <war### [at] tagpovrayorg> wrote:
> geogeo <geo### [at] mecolcouk> wrote:
> > Thanks for info on #debug, had not noticed that feature, only been at this a few
> > days. But how do I get it to output variables? The following #debug fails:
>
> > #declare R1 = seed(1);
> > #declare n = rand(R1);
> > #debug "rand out = ",str(n),"\n";
>
>   #debug takes one single string as parameter. To build a string made of
> several components, you use the concat() function:
>
> #debug concat("rand out = ", str(n, 0, -1), "\n")
>
> --
>                                                           - Warp

Thanks for concat info - works fine now!
Geo


Post a reply to this message

Goto Latest 10 Messages Next 7 Messages >>>

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