Click here to Skip to main content
15,893,622 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I am looking some code to packing 3D spheres with the same radius - r in a rectangle box - xmin, ymin, zmin and xmax, ymax, zmax. In other word, a function with input: r, xmin, ymin, zmin and xmax, ymax, zmax and output: x(i), y(i), z(i), N, which are coordinates of the sphere center and the number of spheres in the box. The packing should be close the highest density with no overlap of spheres. The maximum packing density is 74.05% or the minimum void ratio = 25.95% among various packing.

Packing spheres | plus.maths.org[^][^]

[x,y,z,N]=function spherePackingMinimumVoid (r, xmin, ymin, zmin and xmax, ymax, zmax)

C++, or Fortran or Matlab code.

Thank you

What I have tried:

I tried the least dense packing, which is putting spheres in cube grids. The void ratio is 47.64%, which is not a good packing.
Posted
Updated 8-Jun-19 17:56pm
Comments
OriginalGriff 7-Jun-19 13:59pm    
And? You haven't asked a question!

What have you tried?
Where are you stuck?
What help do you need?

Have a look at Wykobi : http://www.wykobi.com[^]. It is a computational geometry library with a whole bunch of useful algorithms like finding the closest point on a sphere. It could be very useful for you.
 
Share this answer
 
thank you. I looked Wykobi, but nothing there for this problem. Thank you that is a useful code collection
 
Share this answer
 
Comments
Patrice T 9-Jun-19 1:19am    
Use the button "Have a Question or Comment?" to discuss with the author of a solution.
Rick York 10-Jun-19 11:24am    
I disagree. The algorithm I mentioned could be used to do exactly what you are after. There are other similar algorithms that might be useful there also.

You can either keep looking for code that has solved the problem or you can dig in and write it yourself. There are plenty of sites that show the minimal packing. You can write an algorithm that determines the best orientation for the packing. We're not going to do it for you. We have plenty of fun stuff to work on of our own.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900