Let's assume that I start out with a single sphere of a defined radius R, and an array of three elements, containing the cartesian coordinates:
double vecpos[3];
vecpos[0]= 0.0;
vecpos[1]= 0.0;
vecpos[2]= 0.0;
double radius= 5;
Now, I would like to add additional spheres. These additional spheres should be ideally packed, as dense as possible.
I am looking for an algorithm that, starting from this single sphere, will add more ones in a most densly packed way. The spheres may, of course, not overlap (i.e., the behave like solid marbles).
My attempts thus far were centered on adding more spheres (e.g. to the left and right of the original one, so at position:
(10,0,0)
(-10,0,0)
then adding new ones on the top and bottom (at calculated positions:
(5, sqrt(3)/2 * 10, 0)
(-5, sqrt(10)/2 * 10, 0)
(5, sqrt(3)/2 * -10, 0)
(-5, sqrt(3)/2 * -10, 0)
(creating a hexagon of the centers). Up to this point, I realize that I can keep building up new spheres with a simple algorithm which just creates equi-distant triangles which use the centres of two spheres to create a third sphere (this is how I calculated the positions of the four new spheres above).
However, moving into the third dimension (i.e.: Adding new spheres on top or below the others) is where I got stuck, since I don't see a way to intelligently write a code to do it.
Any suggestions which solve my problem or are simpler than my solution are highly welcome.
Thank you.