POV-Ray : Newsgroups : povray.advanced-users : Random number generator needed ! Server Time
26 Nov 2024 04:49:32 EST (-0500)
  Random number generator needed ! (Message 1 to 10 of 41)  
Goto Latest 10 Messages Next 10 Messages >>>
From: Rune
Subject: Random number generator needed !
Date: 20 Feb 2001 14:59:36
Message: <3a92cca8@news.povray.org>
I need a macro that outputs a random number between 0 and 1 when called. It
should have two integers as input. The reason I can't just use rand() and
seed() is that I need it to always output the same random number when the
same input numbers are used.

I need a macro like this: Rand (Int1, Int2)

I don't know anything about random number generators myself, so some help
would be much appreciated.

Rune
--
\ Include files, tutorials, 3D images, raytracing jokes,
/ The POV Desktop Theme, and The POV-Ray Logo Contest can
\ all be found at http://rsj.mobilixnet.dk (updated January 28)
/ Also visit http://www.povrayusers.org


Post a reply to this message

From: Lutz-Peter Hooge
Subject: Re: Random number generator needed !
Date: 20 Feb 2001 15:08:59
Message: <MPG.14fced894ca8ffb1989699@news.povray.org>
hello,

> should have two integers as input. The reason I can't just use rand() and
> seed() is that I need it to always output the same random number when the
> same input numbers are used.

what about:
#macro random(a,b)
	#local S = seed(a+b);
	rand(S)
#end

For what do you need this? A subdivision-surface?

Lutz-Peter


Post a reply to this message

From: Rune
Subject: Re: Random number generator needed !
Date: 20 Feb 2001 15:27:45
Message: <3a92d341@news.povray.org>
"Lutz-Peter Hooge" wrote:
> what about:
> #macro random(a,b)
> #local S = seed(a+b);
> rand(S)
> #end

Already tried such things, but the sequence is not at all random.

> For what do you need this? A subdivision-surface?

No, my particle system. If you want to know more about the particle system,
have a look at the animations recently posted by me in
povray.binaries.animations.

Rune
--
\ Include files, tutorials, 3D images, raytracing jokes,
/ The POV Desktop Theme, and The POV-Ray Logo Contest can
\ all be found at http://rsj.mobilixnet.dk (updated January 28)
/ Also visit http://www.povrayusers.org


Post a reply to this message

From: Ron Parker
Subject: Re: Random number generator needed !
Date: 20 Feb 2001 15:29:15
Message: <slrn995ksu.71c.ron.parker@fwi.com>
On Tue, 20 Feb 2001 21:25:16 +0100, Rune wrote:
>"Lutz-Peter Hooge" wrote:
>> what about:
>> #macro random(a,b)
>> #local S = seed(a+b);
>> rand(S)
>> #end
>
>Already tried such things, but the sequence is not at all random.

It seems what you want is a hash rather than a random number generator.
Whether such a thing is easy or even possible to implement in POV-script
is another question entirely.

-- 
Ron Parker   http://www2.fwi.com/~parkerr/traces.html
My opinions.  Mine.  Not anyone else's.


Post a reply to this message

From: Lutz-Peter Hooge
Subject: Re: Random number generator needed !
Date: 20 Feb 2001 16:17:56
Message: <MPG.14fcfd3048501c4698969a@news.povray.org>
In article <3a92d341@news.povray.org>, run### [at] inamecom says...

> Already tried such things, but the sequence is not at all random.
That depends, of course, on how much random your input variables are. 
if you could somehow feed the output of the macro back to its input 
variables for the next call it would probably be much better.

> No, my particle system. If you want to know more about the particle >system,
> have a look at the animations 
Ah, nice. But i didn't find a message explaning why you need this ramdom 
number generator there.

Lutz-Peter


Post a reply to this message

From: Lutz-Peter Hooge
Subject: Re: Random number generator needed !
Date: 20 Feb 2001 16:21:31
Message: <MPG.14fcfe2434a36dc198969b@news.povray.org>
In article <slr### [at] fwicom>, ron### [at] povrayorg 
says...

> It seems what you want is a hash rather than a random number generator.
> Whether such a thing is easy or even possible to implement in POV-script
> is another question entirely.
I think an array initialized with random numbers could be used for this.
Of course it will need to be very large, or the numbers will repeat much 
more often than in a normal random numer stream.

Lutz-Peter


Post a reply to this message

From: Christoph Hormann
Subject: Re: Random number generator needed !
Date: 20 Feb 2001 16:35:33
Message: <3A92E320.229F7259@gmx.de>
Lutz-Peter Hooge wrote:
> 
> > It seems what you want is a hash rather than a random number generator.
> > Whether such a thing is easy or even possible to implement in POV-script
> > is another question entirely.
> I think an array initialized with random numbers could be used for this.
> Of course it will need to be very large, or the numbers will repeat much
> more often than in a normal random numer stream.
> 

How about using eval_pigment? It would require megapov of course.  It is
not really random, but since you are using integer numbers this should not
be a problem. 

Christoph

-- 
Christoph Hormann <chr### [at] gmxde>
IsoWood include, radiosity tutorial, TransSkin and other 
things on: http://www.schunter.etc.tu-bs.de/~chris/


Post a reply to this message

From: Rune
Subject: Re: Random number generator needed !
Date: 20 Feb 2001 17:30:38
Message: <3a92f00e@news.povray.org>
"Lutz-Peter Hooge" wrote:
> Rune wrote:
> > Already tried such things, but the sequence is not at all random.
>
> That depends, of course, on how much random your input variables are.

Well, since rand(seed(X)) is basically a linear function, all the randomness
would have to come 100% from the input. So there's no point in using it
really.

I even tried things like seed(X*1234567*pi), but even then it only repeats a
few numbers over and over again. Guess it's because a linear function of a
linear function is just another linear function...

> if you could somehow feed the output of the macro back to its
> input variables for the next call it would probably be much
> better.

But I can't.

> i didn't find a message explaning why you need this ramdom number
> generator [in the particle system].

There are many reasons. For example I want my particle system to be
frame-independent, so that the even the randomness of the particles is the
same independent on the frame-rate used. I also need it for the cyclic
animation feature where the whole calculation process is basically run
through several times, and where the random numbers must be the same each
time.

I have considered the array solution myself, but it would have to be a very
large array, and it would be a clumsy solution. :(

Rune
--
\ Include files, tutorials, 3D images, raytracing jokes,
/ The POV Desktop Theme, and The POV-Ray Logo Contest can
\ all be found at http://rsj.mobilixnet.dk (updated January 28)
/ Also visit http://www.povrayusers.org


Post a reply to this message

From: Rune
Subject: Re: Random number generator needed !
Date: 20 Feb 2001 17:30:40
Message: <3a92f010@news.povray.org>
"Christoph Hormann" wrote:
> How about using eval_pigment?

That might work, but is there any of the "random" patterns that have
completely equally distributed values?

Rune
--
\ Include files, tutorials, 3D images, raytracing jokes,
/ The POV Desktop Theme, and The POV-Ray Logo Contest can
\ all be found at http://rsj.mobilixnet.dk (updated January 28)
/ Also visit http://www.povrayusers.org


Post a reply to this message

From: Rune
Subject: Re: Random number generator needed !
Date: 20 Feb 2001 17:30:41
Message: <3a92f011@news.povray.org>
"Lutz-Peter Hooge" wrote:
> I think an array initialized with random numbers could be
> used for this. Of course it will need to be very large, or
> the numbers will repeat much more often than in a normal
> random numer stream.

At first I thought the array needed would be too large, but wouldn't it work
to make a relative small array, and then use averages of different numbers
from the array?

If 3 numbers from the array were averaged the amount of different numbers
would be array_length^3 and if 8 numbers were averaged it would be ^8 !

Maybe this is the solution?

Rune
--
\ Include files, tutorials, 3D images, raytracing jokes,
/ The POV Desktop Theme, and The POV-Ray Logo Contest can
\ all be found at http://rsj.mobilixnet.dk (updated January 28)
/ Also visit http://www.povrayusers.org


Post a reply to this message

Goto Latest 10 Messages Next 10 Messages >>>

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