Crate hex_coordinates
source · [−]Expand description
A library for handling hex coordinates.
Massive credit to Hexagonal Grids from Red Blob Games.
| Offset | Doubled | Axial th> | Cube | |
|---|---|---|---|---|
| Pointy rotation | evenr, oddr | doublewidth | axial | cube |
| Flat rotation | evenq, oddq | doubleheight | ||
| Other rotations | no | yes | ||
| Vector operations (add, subtract, scale) | no | yes | yes | yes | tr>
| Array storage | rectangular | no* | rhombus* | no* |
| Hash storage | any shape | any shape | ||
| Hexagonal symmetry | no | no | no | yes |
| Easy algorithms | few | some | most | most |
The article notes:
My recommendation: if you are only going to use non-rotated rectangular maps, consider the doubled or offset system that matches your map orientation. For maps with rotation, or non-rectangularly shaped maps, use axial/cube. Either choose to store the s coordinate (cube), or calculate it when needed as -q-r (axial).
Structs
CubeCoordinates minus s coordinate.
A wrapper to make a field immutable.
Enums
This is arguably excessively explicit, but I want to specify when passing this parameter it relates to the columns being even or odd.
This is arguably excessively explicit, but I want to specify when passing this parameter it relates to the rows being even or odd.