https://www.redblobgames.com/blog/2025-03-12-hexagon-spiral-coordinates/ Hexagon spiral coordinates from Red Blob Games's Blog * Home * Blog * Links * Bluesky * About * * [ ] Blog post: 12 Mar 2025 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]. One of them has been spiral coordinate systems. I had thought I would wait until I actually use them in a real project, so that I would have real world experience with the thing I'm writing about. I'm afraid of writing about things I'm unsure about, or information that's incomplete. But I haven't used them yet. I decided to stop waiting. [2025-hexag]Spiral coordinates on a hexagonal grid I decided to make some diagrams showing the parts I do understand. This also led me to try to understand more. I gave some unoptimized sample code. Part of me wanted to wait until I have the best sample code to present. But ... I've already been waiting for so many years. I decided to publish the unoptimized code for now. 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. But if I wait until I have figured out all of these, it will take even longer. So I published just one variant for now. Take a look at the new section^[3]. Please let me know what you'd like to see changed or improved! 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: [hexagon-ps]Something angle-like that can be used for sorting by angle That's not a topic I wanted for the main page, so I put it on a separate page^[4]. Email me redblobgames@gmail.com, or comment here: Links 1. [1]: https://www.redblobgames.com/grids/hexagons/ 2. [2]: https://redblobgames.notion.site/ Hexagonal-Grids-7d2d4d624bc5483dafbe615d75ab3902 3. [3]: https://www.redblobgames.com/grids/hexagons/# rings-spiral-coordinates 4. [4]: https://www.redblobgames.com/grids/hexagons/directions.html# angles Load comments View the discussion thread. Copyright (c) 2025Red Blob Games RSS Feed Created 12 Mar 2025; Last modified: 12 Mar 2025