A reader asked how to find all the hexagon shapes that fit inside a circle. I implemented this diagram with a slider. Red circles are integer distances and black circles are other distances.
Brute force solution:
- You need a distance function. For each hex you need to know the distance from 0,0 to to the furthest corner. I have a javascript version of this in hexagons-in-circle.js (
distanceToCorner
). - You need to know all the distances. If you loop over all the hexes, you can calculate
distanceToCorner
to each. Then get all the unique distances form this list. Sort them. Little glitch: sometimes two values are very very close together and we probably want to lump them together, so in this code I lumped together values that were the same down to 4 digits. See the calculation ofallDistances
in hexagons-in-circle.js. Each of the distances in
allDistances
gives you a diagram, with hexes withdistanceToCorner(hex) < distance
. Little glitch: because I'm using 4 digits, sometimes there are rounding errors, and I had to usedistanceToCorner(hex) < distance + 0.00005
I could not find a closed form formula to find the distances, but I didn't try very hard. I think brute force worked just fine here.