Get the latest tech news

Hexagon Spiral Coordinates


My guide to hexagonal grids[1] is one of the most popular pages on my site. I keep a list of things I want to add to that page[2].

Spiral coordinates on a hexagonal gridI decided to make some diagrams showing the parts I do understand. There are also lots of variants I could have covered: 0-based vs 1-based, outside-in vs inside-out, ring-based vs path-based, uniform direction vs alternating direction, single spiral vs recursive spirals, and probably more. While working on this, I also added an accidental discovery: running atan2(r,q) on axial coordinates instead of atan2(y,x) on cartesian coordinates produces something angle-like that can be used for sorting by angle, while being slightly cheaper than actually calculating the angles:

Get the Android app

Or read this on Hacker News