POV-Ray : Newsgroups : povray.binaries.images : seven arms : Re: seven arms Server Time
31 Jul 2024 14:34:59 EDT (-0400)
  Re: seven arms  
From: Chris B
Date: 15 Aug 2009 06:05:45
Message: <4a868879$1@news.povray.org>
"bgimeno" <bgimeno[at]persistencia[dot]org> wrote in message 
news:4a865de4@news.povray.org...
> While experimenting with the function rand () to simulate a random 
> distribution of trees, (moving object at a random distance from origin and 
> then doing it orbit on the y-axis, when I found this.
> I've noticed a pattern when attempting to distribute objects on a square 
> grid. But why this circular distribution?
>
> ... snip ...
>
> #local Num_Tree = 0 ;
> #while (Num_Tree<1000)
>  #local rnd_tree = seed (Num_Tree);
>  #if (rand (rnd_tree)<.95 )
>    object {Tree
>            translate <50*rand(rnd_tree),0,0>
>            rotate y*360*rand(rnd_tree)
>            }
>   #end
>  #local Num_Tree = Num_Tree +1 ;
> #end
>
>
> pd. I found it while editing the code to upload the image. The key is in 
> the use of the same rand value to control the density of generating 
> objects. But interesting anyway.
> pd2 google searchs results: "the seven arms of Shiva", "the seven arms of 
> the Menorah", "an Octopus with only seven arms"...
>

Take your pick:
Answer A: Yes it's controlled by ancient deities.
Answer B: You're using the seed function wrong.

Answer B continued:
Because the seed function is being called from within the #while loop you 
are simply stepping sequentially through the seeds rather than taking 
successive numbers from a random number stream. If you move the seed 
definition outside the loop and use a single number as the seed you should 
avoid this problem ie use:
#local rnd_tree = seed (0);
and move it so that it's set before starting the #while loop.

This characteristic of the seed/rand functions was discussed in some detail 
in a long thread quite a while ago:
http://news.povray.org/povray.binaries.images/thread/%3Cweb.4a0d5729a7098c1c34d207310@news.povray.org%3E/
I don't remember seeing anything there that explains what it is that will 
give you 7 arms rather than a different number of arms, so this is maybe 
where Answer A and Answer B mysteriously come together.

The other thing to note is that even when you fix this, your algorithm still 
gives a cluster at the centre of the circle, but the reason for this is 
categorically mathematical :o)

Regards,
Chris B.


Post a reply to this message

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