Hacker News new | ask | show | jobs
by lorddoig 4067 days ago
Hexagonal packing is good but hexagonal packing into a hexagon appears to be leaving the edges of your search radius uncovered.

The packing density is about aligning on a hexagonal lattice, the points of which are a simple function of the inner circle's radius - the points in each row are 2r apart and every other row is horizontally offset by 2r * tan(60) (I hope that's right). Could you not build a row of circles out from the center to the right edge and copy it to the rows above, offsetting as required? The length of any given row is then half of the chord it sits on i.e. sqrt(r^2 - d^2) where d is the distance from the center, in this case 2r * row-index -- with this you can then filter out which circles are outside the containing circle for that row. This fills the top-right quarter segment of the circle, and the whole thing can be filled by flipping the coordinates along x to get the bottom right, and flipping all of that along y to get the other half, then dedup the cross that forms in the middle.

I think, in terms of coverage, this must always be at least as good as a hexagon built out from the center, but that should be a rare case and most of the time it'd be better.

Evidently I'm not a mathematician. Am I being stupid here?