POV-Ray : Newsgroups : povray.newusers : Spheres in a sphere : Re: Spheres in a sphere Server Time
1 Jun 2024 12:36:26 EDT (-0400)
  Re: Spheres in a sphere  
From: Alain
Date: 24 Mar 2014 13:51:26
Message: <5330709e@news.povray.org>


>
> I improve my code but spheres stay together.
> This is the new code :
> #include "rand.inc"
> #declare Random_1 = seed (12433);
> #declare ArrayPosition=array[3000]
> #declare ArrayRayon=array[3000]

ALL your spheres have the exact same radius. This mean that the above 
array is superfluous. Replace it with a simple scalar variable.

#declare Rayon = 0.05;

> #declare Variable=0;
>
> #while (Variable<3000)
>          #declare ArrayPosition[Variable]=VRand_In_Sphere(Random_1);

Remove the following line.
>          #declare ArrayRayon[Variable]=0.05;
>          #declare Variable=Variable+1;
> #end
>
> #declare Variable1=0;
> #declare Variable2=1;
>
> #declare Object=sphere{ArrayPosition[Variable1] ArrayRayon[Variable1] pigment
> {rgb <1,0,0>}}

Use your simple Rayon variable MULTIPLIED by 2!
Also, as this object will NEVER show, it don't need to have any pigment, 
giving you this:
#declare Object=sphere{ArrayPosition[Variable1] Rayon*2}

Doubling "Rayon" ensure that the points you find are far enough from the 
others to prevent any spheres from overlapping.

Make the same change in the loop below:

> #declare Point=ArrayPosition[Variable2];
>
> #while (Variable2<2999)
>          #while (Variable1<Variable2)
>                  #if(inside(Object,Point))
>                  #declare ArrayRayon[Variable2]=0;
>                  #declare Variable1=Variable2;
>                  #else
>                  #declare Variable1=Variable1+1;
>                  #declare Object=sphere{ArrayPosition[Variable1]
> Rayon*2 }
>                  #end
>          #end
>          #declare Variable2=(Variable2+1);
>          #declare Variable1=0;
>          #declare Object=sphere{ArrayPosition[Variable1] Rayon*2}
>
>          #declare Point=ArrayPosition[Variable2];
>
> #end
>

The following spheres are those that ARE visible and need the pigment.

> #declare Variable=0;
> #while (Variable<2999)
> sphere{ArrayPosition[Variable] Rayon pigment {rgb
> <0.85,0.85,0.85>}}
> #declare Variable=Variable+1;
> #end
>
>
> Any suggestions about my error ?
>
> Thanks
>
>

PS.: If you have trouble in english, send me your e-mail address. French 
is my native language, and your naming suggest that it's the same for you.



Alain


Post a reply to this message

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