POV-Ray : Newsgroups : povray.newusers : seed Server Time
13 Nov 2024 22:25:49 EST (-0500)
  seed (Message 1 to 6 of 6)  
From: kobus
Subject: seed
Date: 23 Feb 2000 17:53:26
Message: <01bf7e50$a4f58320$667dd383@etnica.ibb.uu.nl>
Hello there, 

I have a question about random and seed. First one have to declare seed(A).
Will random then return a value between A and A+1? If that is the case I
understood the manual correctly. 

thanks, kobus


Post a reply to this message

From: Ken
Subject: Re: seed
Date: 23 Feb 2000 17:57:31
Message: <38B46581.3005AAEB@pacbell.net>
kobus wrote:
> 
> Hello there,
> 
> I have a question about random and seed. First one have to declare seed(A).
> Will random then return a value between A and A+1? If that is the case I
> understood the manual correctly.
> 
> thanks, kobus

Rand will always return a value from 0 to 1. The seed number will determine
where between 0 and 1 the value starts.

-- 
Ken Tyler -  1300+ Povray, Graphics, 3D Rendering, and Raytracing Links:
http://home.pacbell.net/tylereng/index.html http://www.povray.org/links/


Post a reply to this message

From: Chris Huff
Subject: Re: seed
Date: 23 Feb 2000 18:04:16
Message: <chrishuff_99-35DFA2.18053823022000@news.povray.org>
In article <01bf7e50$a4f58320$667dd383@etnica.ibb.uu.nl>, "kobus" 
<kob### [at] hotmailcom> wrote:

> Hello there, 
> 
> I have a question about random and seed. First one have to declare 
> seed(A).
> Will random then return a value between A and A+1? If that is the case I
> understood the manual correctly. 

The rand() function always returns a value between 0 and 1. Specifying a 
different seed will just give a different sequence of random numbers.
Most computer random number generators are actually pseudo-random. They 
produce a specific sequence of numbers from each seed value. If you use 
seed(444), you will get a different sequence from what you would get if 
you used seed(999), and that sequence will always be the same.

-- 
Chris Huff
e-mail: chr### [at] yahoocom
Web page: http://chrishuff.dhs.org/


Post a reply to this message

From: Jean-Michel Grimaldi
Subject: Re: seed
Date: 24 Feb 2000 07:46:38
Message: <38B52852.548D6481@via.ecp.fr>
Chris Huff wrote:
> 
> If you use, seed(444), you will get a different sequence from
> what you would get if you used seed(999), and that sequence
> will always be the same.

Yes, and thus your image will always render the same.
As for the initial question, do the following :
 s = seed(1234) ;
 [...] A+random(s) [...]
This way you will get a number between A and A+1.
And if the result is not satisfying, just change 1234 into something
else.

-- 
JM


Post a reply to this message

From: Chris Huff
Subject: Re: seed
Date: 24 Feb 2000 08:08:06
Message: <chrishuff_99-3AA9E6.08093024022000@news.povray.org>
In article <38B52852.548D6481@via.ecp.fr>, Jean-Michel Grimaldi 
<jm### [at] viaecpfr> wrote:

> Yes, and thus your image will always render the same.
> As for the initial question, do the following :
>  s = seed(1234) ;
>  [...] A+random(s) [...]
> This way you will get a number between A and A+1.
> And if the result is not satisfying, just change 1234 into something
> else.

Not "random()", "rand()". But this gives me an idea...

#macro random(Sd, Mn, Mx)
   (rand(Sd)*(Mx-Mn) + Mn)
#end

Now, this should let you use "random(stream, min_limit, max_limit)" for 
your random numbers, where stream is the variable initialized by seed(). 
The other two should be pretty explanatory.
I haven't had time to test it though. :-)

#declare S = seed(589743);
sphere {< random(S,-1, 2), 0, 0>, 0.1}

-- 
Chris Huff
e-mail: chr### [at] yahoocom
Web page: http://chrishuff.dhs.org/


Post a reply to this message

From: Margus Ramst
Subject: Re: seed
Date: 24 Feb 2000 08:26:32
Message: <38B53204.92AA285A@peak.edu.ee>
Chris Huff wrote:
> 
> Not "random()", "rand()". But this gives me an idea...
> 

Two macros that do the same, used & tested:

//Create random number of given mean and maximum deviation
//M - mean value
//D - maximum deviation
//Seed - (declared) random number seed identifier
#macro rand_ext(M,D,Seed)
        (M+(rand(Seed)-.5)*2*D)
#end

//Give a random vector of given mean and max deviation
//M - mean (vector or float)
//D - max deviation (vector or float)
//Seed - (declared) random number seed identifier
#macro v_rand_ext(M,D,Seed)
        #local MV=M+<0,0,0>;
        #local DV=D+<0,0,0>;
(<rand_ext(MV.x,DV.x,Seed),rand_ext(MV.y,DV.y,Seed),rand_ext(MV.z,DV.z,Seed)>)
#end


Post a reply to this message

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