POV-Ray : Newsgroups : povray.newusers : random elements in blob object Server Time
4 Nov 2024 19:16:37 EST (-0500)
  random elements in blob object (Message 1 to 10 of 24)  
Goto Latest 10 Messages Next 10 Messages >>>
From: koos
Subject: random elements in blob object
Date: 2 Feb 2002 02:30:37
Message: <01c1abbb$9437bf40$667dd383@etnica>
Hello all, 

I am trying to create a blob object with a number of sphere, but I am
trying to place them at random. Now the following problem occurs, all
sphere are placed at the same position. The objection, of course, is to see
all the spheres. My code is as follows:

#declare bubbles = blob
{
  threshold 0.5
  #declare i = 0;
  #while (i<50)
    #declare S = seed(3415765);
    #declare X = rand(S);
    #declare Y = (rand(S)*2)+0.5;
    #declare Z = rand(S);
    sphere { <X, Y, Z>, 0.4, 0.55
      pigment { color rgb <0.8, 0.3, 0.6> }
    }
    #declare i = i + 1;
  #end
}

Any help would be appreciated, 
Koos Jan Niesink


Post a reply to this message

From: ingo
Subject: Re: random elements in blob object
Date: 2 Feb 2002 03:00:32
Message: <Xns91A95BEAD1569seed7@povray.org>
in news:01c1abbb$9437bf40$667dd383@etnica koos wrote:

> #declare bubbles = blob
> {
>   threshold 0.5
>   #declare i = 0;
>   #while (i<50)
>     #declare S = seed(3415765);
> 

Mogge,

Take "#declare S = seed(3415765);" out of the while loop and put it above 
"#declare bubbles=".


Ingo


Post a reply to this message

From: koos
Subject: Re: random elements in blob object
Date: 2 Feb 2002 03:22:19
Message: <01c1abc2$cd6f19a0$667dd383@etnica>
Thanks, for the help. It really works!!
I only don't get the reason why the seed declaration has to be placed
outside the while-loop. 

greetings/groeten, Koos Jan Niesink

ingo <ing### [at] homenl> schreef in artikel
<Xns### [at] povrayorg>...
> in news:01c1abbb$9437bf40$667dd383@etnica koos wrote:
> 
> > #declare bubbles = blob
> > {
> >   threshold 0.5
> >   #declare i = 0;
> >   #while (i<50)
> >     #declare S = seed(3415765);
> > 
> 
> Mogge,
> 
> Take "#declare S = seed(3415765);" out of the while loop and put it above

> "#declare bubbles=".
> 
> 
> Ingo
>


Post a reply to this message

From: ingo
Subject: Re: random elements in blob object
Date: 2 Feb 2002 03:50:18
Message: <Xns91A9645ADF8A2seed7@povray.org>
in news:01c1abc2$cd6f19a0$667dd383@etnica koos wrote:

> Thanks, for the help. It really works!!

Gaaf he.

> I only don't get the reason why the seed declaration has to be placed
> outside the while-loop. 

#declare S= seed(7) intialises a random stream.
#declare Nr1= rand(S) takes the first random number from the stream.
#declare Nr2= rand(S) takes the second.
#declare Nr3= rand(S) the third.

Note that every time you render your scene Nr1 alway gets the same 
value. Now if you put #declare S= seed(7) inside a loop, it gets 
initialised every time the loop passes it. Thus the value of Nr1 will 
always be the same.
Put the seed outside the loop, it is only initialised once. On the first 
loop we will get the above result. On the second loop:

#declare Nr1= rand(S) takes the fourth random number from the stream.
#declare Nr2= rand(S) takes the fifth.
#declare Nr3= rand(S) the sixth.
etc.

The order of random numbers for a given seed is always the same.

Ingo


Post a reply to this message

From: Warp
Subject: Re: random elements in blob object
Date: 2 Feb 2002 04:57:46
Message: <3c5bb819@news.povray.org>
koos <fra### [at] hotmailcom> wrote:
: I only don't get the reason why the seed declaration has to be placed
: outside the while-loop. 

  If you initialize the random number generator with the same value at
each loop, you'll get the same value from rand().
  A line like:

#declare S = seed(0);

means: "Make S a random number stream with the initial value 0". Successive
rand(S) calls will take values from that seed (and they are always the same
values).

-- 
#macro M(A,N,D,L)plane{-z,-9pigment{mandel L*9translate N color_map{[0rgb x]
[1rgb 9]}scale<D,D*3D>*1e3}rotate y*A*8}#end M(-3<1.206434.28623>70,7)M(
-1<.7438.1795>1,20)M(1<.77595.13699>30,20)M(3<.75923.07145>80,99)// - Warp -


Post a reply to this message

From: Nekar Xenos
Subject: Re: random elements in blob object
Date: 3 Feb 2002 06:32:17
Message: <3c5d1fc1@news.povray.org>
"ingo" <ing### [at] homenl> wrote in message
news:Xns### [at] povrayorg...
> in news:01c1abc2$cd6f19a0$667dd383@etnica koos wrote:
>
> > Thanks, for the help. It really works!!
>
> Gaaf he.
>

Dutch?

--
#local X=20*<-2,2,5>;sphere_sweep{catmull_rom_spline 6<-8,-8>1<-8,-8>1<-8,8>1<
8,-8>1<8,8>1<8,8>1translate 20*z pigment{gradient z scale 3color_map{[0rgb<0,9
,18>][1rgb 0]}}}#local K=2*z*X-X;#local R=seed(clock);blob{#while(K.x>X.x)
#local N=X+<rand(R)rand(R)1>/3;#local X=(vlength(N-K)<vlength(X-K)?N:2*X-N);
sphere{X,1,1rotate z*90}sphere{X,1,1}#end pigment{rgbt 1}interior{media{//Nekar
emission<2,4,5>*5}}hollow scale.05}//   http://nekar_xenos.tripod.com/metanoia/


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.317 / Virus Database: 176 - Release Date: 2002/01/21


Post a reply to this message

From: ingo
Subject: Re: random elements in blob object
Date: 3 Feb 2002 06:44:26
Message: <Xns91AA81E131676seed7@povray.org>
in news:3c5d1fc1@news.povray.org Nekar Xenos wrote:

> Dutch?
> 

Ja.

Ingo


Post a reply to this message

From: Koos Jan Niesink
Subject: Re: random elements in blob object
Date: 4 Feb 2002 04:36:40
Message: <3c5e5628$1@news.povray.org>
Inderdaad ;-)
thanks for the explanation

In article <Xns### [at] povrayorg>, "ingo" <ing### [at] homenl>
wrote:


> in news:3c5d1fc1@news.povray.org Nekar Xenos wrote:
>> Dutch?
>> 
> Ja.
> Ingo


Post a reply to this message

From: Nekar Xenos
Subject: Re: random elements in blob object
Date: 4 Feb 2002 07:37:15
Message: <3c5e807b@news.povray.org>
"Koos Jan Niesink" <koo### [at] hotpopcom> wrote in message
news:3c5e5628$1@news.povray.org...
> Inderdaad ;-)
> thanks for the explanation
>
> In article <Xns### [at] povrayorg>, "ingo" <ing### [at] homenl>
> wrote:
>
>
> > in news:3c5d1fc1@news.povray.org Nekar Xenos wrote:
> >> Dutch?
> >>
> > Ja.
> > Ingo

Dit lyk vir my daar is heelwat meer Nederlanders hier as wat ek gedink het. Ek
vermoed hier is dalk ook 'n paar Vlaams sprekendes? Verskoon my spelling - ek is
Afrikaans.

I didn't see any [NE] on the povray.international so I never looked there
again...

--
#local X=20*<-2,2,5>;sphere_sweep{catmull_rom_spline 6<-8,-8>1<-8,-8>1<-8,8>1<
8,-8>1<8,8>1<8,8>1translate 20*z pigment{gradient z scale 3color_map{[0rgb<0,9
,18>][1rgb 0]}}}#local K=2*z*X-X;#local R=seed(clock);blob{#while(K.x>X.x)
#local N=X+<rand(R)rand(R)1>/3;#local X=(vlength(N-K)<vlength(X-K)?N:2*X-N);
sphere{X,1,1rotate z*90}sphere{X,1,1}#end pigment{rgbt 1}interior{media{//Nekar
emission<2,4,5>*5}}hollow scale.05}//   http://nekar_xenos.tripod.com/metanoia/


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.317 / Virus Database: 176 - Release Date: 2002/01/21


Post a reply to this message

From: Tom Melly
Subject: Re: random elements in blob object
Date: 4 Feb 2002 09:29:28
Message: <3c5e9ac8$1@news.povray.org>
"koos" <fra### [at] hotmailcom> wrote in message
news:01c1abbb$9437bf40$667dd383@etnica...

<snip>

Well, you've had answers to your initial problem.

Here's a subtler trap with random streams....

#declare S1 = seed(32534);
#while(1=1)
    #declare S2 = seed(rand(S1))
    object{foo translate y*rand(S2)}
#end

Here, you get some variation for rand(S2), but not a lot. This is because the
seed to S2 is always in the range 0 -> 1, which returns a random stream with
very little variation.


Post a reply to this message

Goto Latest 10 Messages Next 10 Messages >>>

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