random h3-related notes
- https://www.gamasutra.com/blogs/HermanTulleken/20140912/225495/20_Fun_Grid_Facts_Hex_Grids.php
- http://www.gamelogic.co.za/downloads/HexMath2.pdf
- https://www.redblobgames.com/grids/hexagons/
bit layout
H3 cell
name | # of bits | value(s) |
---|---|---|
reserved | 1 | 0 |
mode | 4 | 1 |
reserved | 3 | 0 |
resolution | 4 | 0–15 |
base cell # | 7 | 0–121 |
digit 1 | 3 | 0–7 |
\(\vdots\) | \(\vdots\) | \(\vdots\) |
digit 15 | 3 | 0–7 |
Note that \(1 + 4 + 3 + 4 + 7 + 3 \cdot 15 = 64\).
Cell parents/children
name | # of bits | value(s) | parent | child |
---|---|---|---|---|
reserved | 1 | 0 | 0 | 0 |
mode | 4 | 1 | 1 | 1 |
reserved | 3 | 0 | 0 | 0 |
resolution | 4 | 0–15 | 1 | 2 |
base cell # | 7 | 0–121 | 37 | 37 |
digit 1 | 3 | 0–7 | 2 | 2 |
digit 2 | 3 | 0–7 | 7 | 5 |
digit 3 | 3 | 0–7 | 7 | 7 |
child < parent
H3 directed edge
name | # of bits | value(s) |
---|---|---|
reserved | 1 | 0 |
mode | 4 | 2 |
edge direction | 3 | 1–6 |
resolution | 4 | 0–15 |
base cell # | 7 | 0–121 |
digit 1 | 3 | 0–7 |
\(\vdots\) | \(\vdots\) | \(\vdots\) |
digit 15 | 3 | 0–7 |
random
Cells
A hexagon’s 7 children are numbered
0,1,2,3,4,5,6
in the next resolution digit.
A pentagon’s 6 children are numbered
0,2,3,4,5,6 (skips 1)
in the next resolution digit.
Vertices
Since each vertex is incident to 3 cells, but we also want H3 index uniqueness, we have to choose just one of these cells to be the “owner” of the vertex.
A hexagon’ 6 vertices are numbered
0,1,2,3,4,5
in the “reserved/mode-dependent” bits.
A pentagons’ 5 vertices are numbered
0,1,2,3,4,5 (no skip)
in the “reserved/mode-dependent” bits.
Last update:
October 31, 2022