2013: I spent 8 weeks instead of 2 on the hex grid guide, and there's still so much I could add. All potential additions and changes will go on this trello card. However I'm not guaranteeing that I'll work on these. I just don't want to lose them.
2015: I wrote the procedural hex code generator, and also updated some of the diagrams on the hex grid page
2018: I spent 7 weeks to rewrite all the code, improve diagrams, and make new diagrams, and then added doubled coordinates:
2021: I spent 1 week to change code to use q,r,s instead of x,z,y, and also change many sections to treat axial and cube together instead of focusing primarily on cube coordinates. Now treating axial and cube as essentially the same system, but cube stores s preemptively and axial calculates s as needed.
2022: I spent 1 day to bring the implementation guide and main page more into alignment, mostly to match the x,z,y→q,r,s change from last year. The main page used Hex
for axial and Cube
for cube but the implementation page used Hex
for cube, so I changed the main page to use Axial
for axial. The implementation guide needed lots of small changes to make it match the main page.
Unclassified
- [x] Simplify code for drawing a hexagon. Geometry section should explain that we're picking points on the circle (right now it just says to use sqrt(3) without explaining where that comes from). Also, using the inscribed circle we can pick the center of the edges. The smaller circle may also be a useful guide for artwork size. --> ended up drawing the circumcircle without explaining it.
- [x] For sliding map rows, also describe the implicit calculation of the row start, which can be used for fixed map shapes. For rectangular shapes, this ends up being equivalent to translating into offset coordinates.
- [ ] Implement better field of view algorithm, using angle ranges. More precise and also faster.
- [x] Explain how to find the intersection between two hexagonal areas (filled rings). Treat a filled ring as x0 ≤ x ≤ x1, y0 ≤ y ≤ y1, z0 ≤ z ≤ z1. Then the intersection will be the AND of the two sets of equations. To implement efficiently, you can directly iterate over the solutions instead of trying all values and testing if the inequalities hold.
- [x] Look at offset coordinate hex distance formula on http://stackoverflow.com/questions/20290140/calculate-grid-distance-between-hexagons --> looks like it's essentially converting to axial
- [x] Explain implementation notes, like [3] instead of x,y,z, and &1 instead of %2
- [x] For line drawing, @dour suggests that float rounding might work (not needing hex rounding). Try this out. See tweet: https://twitter.com/dour/status/390033066988564480
- [ ] Drawing the edges of hexagons, for drawing a grid (use edge coordinates, or alternatives)
- [x] Generate maps of various shapes --> done on the implementation page
- [x] Map storage should give sample code, and also describe how you need to loop over coordinates using
first_column
and row_length
.
- [ ] Central Place Theory https://www.e-education.psu.edu/geog597i_02/node/684