When needeing to pack cylindrical stuff in a box or other shape the most space efficient way it to use hexagon packing.
Here is my try on making a set of functions for open scad that compute the hexagonal coordinate system and the translations for cylidrical items.
The functions are heavely based on the research and tutorial found on :
https://www.redblobgames.com/grids/hexagons/implementation.html
the project is also hosted on the git repository for more details: https://github.com/tiberiucorbu/openscad_hex_pack_lib
cube_coordinates.stl | 161.8KB | |
hexpack-constants.scad | 584.0B | |
hexpack.example.scad | 4.5KB | |
hexpack.scad | 3.6KB |