POV-Ray : Newsgroups : povray.newusers : Spheres in a sphere : Re: Spheres in a sphere Server Time
14 May 2024 14:19:18 EDT (-0400)
  Re: Spheres in a sphere  
From: nonostar
Date: 23 Mar 2014 16:05:01
Message: <web.532f3e029f83cd6812fd452f0@news.povray.org>
"nonostar" <nomail@nomail> wrote:
> Alain <kua### [at] videotronca> wrote:

> > > Hello,
> > >
> > > i want to make spheres in a sphere. I know there is a function for that :
> > > VRand_In_Obj.
> > >
> > > But i want to prevent the intersection of spheres between them.
> > >
> > > How can i do proceed to do that ?
> > >
> > > Thanks for your help
> > >
> > >
> >
> > A common and simple solution for equaly sized spheres:
> > Create an array large enough to contain the locations of all your spheres.
> > Randomly place about 10 to 100 spheres. Make sure that the new spheres
> > are located at twice the individual radius. Each acceptable location is
> > placed in the array.
> > Make an union of test spheres, each having twice the radius of your
> > intended spheres.
> > Now, for the next spheres, start with an insideness test against that
> > union. There is an is_inside function that return 0 if outside an object
> > and 1 if inside.
> > Continue for another batch of spheres that will also be used to create
> > another union.
> > Repeat untill you have all yours spheres, or you need to many tries to
> > find a suitable location.
> >
> > Finaly, using the locations from your array, place the actual spheres.
> >
> > Using a bunch of unions of double sized spheres is much faster than
> > testing for every previous spheres.
> >
> > This don't ensure the most optimum packing, but ensure that all spheres
> > are non-intersecting.
> >
> > If you search in povray.binaries.scene-files, you can find some working
> > code made exactly for that purpose.
> >
> >
> > Alain
>
> Thanks for these answers.
> I will try to do it step by step with time because i am a new user on this
> software.
> i inform you.

Hello

This is that i did. But some sphere are again to gether.
Where is the problem?
I use the function : inside.

#include "rand.inc"
#declare Random_1 = seed (12433);
#declare Tableau=array[3000]
#declare Tableau2=array[3000]
#declare Variable=0;
#while (Variable<3000)
#declare Tableau[Variable]= VRand_In_Sphere(Random_1);
#declare Variable=Variable+1;
#end

#declare VariableX=0;
#declare Variable=1;
#declare S1=Tableau[0];
#declare B1=sphere{S1 0.05 pigment {rgb <1,1,0>}}
#declare Point=Tableau[1]  ;
#while (Variable<3000)
    #while (VariableX<=Variable)
        #if (inside(B1,  Point))
        #declare Tableau2[Variable]=0 ;
        #declare VariableX=VariableX+1;
        #declare S1=Tableau[VariableX];
        #else
        #declare Tableau2[Variable]=0.05;
        #end
    #declare VariableX=VariableX+1;
    #end
    #declare Variable=Variable+1;

#end
//---------------------------------------------------------

#declare Variable=1;
#declare Variable2=1;
#while (Variable<3000)
#declare S2=Tableau[Variable];
#declare S3=Tableau2[Variable];
sphere{S2 S3 pigment{rgb<1,1,0>}}
#declare Variable=Variable+1;
#declare Variable2=Variable2+1;
#end


Can you help me?

Thanks


Post a reply to this message

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