|
![](/i/fill.gif) |
in news:3b77cd84@news.povray.org Gail Shaw wrote:
> // very pseudo-code
>
> #declare ObjectsArray=array[4] {Object1,Object2,Object3,Object4}
> #declare ProbArray = array[4] {0.5,0.2,0.2,0.1}
>
> Pile(ObjectsArray,ProbArray)
>
> In the above case 50% of the pile will be object1, 20% object2 etc
>
>
You'll have to do it in a few steps:
1. generate a random integer number in the range 0 to len(ProbArray)-1
2. use the resulting number as input for the ProbArray and retreive the
probability.
3. generate a random number in the range 0-1, check if it is smaller or
equal to the probability.
4. if no, start all over again.
5 if yes, take the number you found in step two and use it as input in
the ObjectsArray.
Ingo
--
Photography: http://members.home.nl/ingoogni/
Pov-Ray : http://members.home.nl/seed7/
Post a reply to this message
|
![](/i/fill.gif) |