code wiki / _hdl_build / nx_geo_h3.nx

nx_geo_h3.nx

buildroot/runtime/_hdl_build/nx_geo_h3.nx

2608 B63 linesdepth 2pulls 2 transitivereach 1 importersview sourcekind librarytopic geo
docsdependenciesstructsconstsfunctions

about

nx_geo_h3.nx -- LIB: GEO-018 H3-CLASS HEXAGONAL grid index in CUBE coordinates. A hex cell is (q,r,s) with q+r+s=0; the 6 neighbours are the 6 axial directions, each at grid-distance 1. THE EXCEED ANGLE (measured, integer-exact -- not asserted): hexagons tile the plane with UNIFORM adjacency. The exact squared Euclidean distance between two hex-lattice centres differing by axial (da,db) is the lattice NORM FORM N(da,db) = da^2 + da*db + db^2 -- the irrational sqrt(3) of the hex basis CANCELS, leaving a pure integer. All 6 immediate neighbours have N == 1: every adjacent hex is equidistant. A square grid's natural 8-neighbourhood instead splits into squared distance 1 (4 edge) and 2 (4 diagonal) -- NON-uniform by a factor of 2. Uniform adjacency = no direction-dependent bias in coverage / radius / flow, the H3 win over square cells. Pure integer, deterministic. (q,r) are axial cell coords; a real lon/lat first quantizes to the hex lattice. license_tier: ORIGINAL

dependencies 1 imports · 1 importers

nx_syscalls.nx nx_geo_h3.nx nx_geo_h3_gate.nx

imports: nx_syscalls.nx

imported by: nx_geo_h3_gate.nx

structs

none

consts

none

functions

16func geo_h3_abs(x: i64) -> i64 { if x < 0 { return 0 - x } return x }
called by 1: geo_hex_distance
19func geo_hex_axial_to_cube(q: i64, r: i64, out3: *i64) -> i64
called by 1: main
27func geo_hex_distance(q1: i64, r1: i64, q2: i64, r2: i64) -> i64
called by 1: main calls 1: geo_h3_abs
35func geo_hex_norm2(da: i64, db: i64) -> i64
called by 1: main
40func geo_hex_neighbor(q: i64, r: i64, dir: i64, out2: *i64) -> i64
called by 1: main
55func geo_hex_ring_size(k: i64) -> i64
called by 1: main
61func geo_hex_disk_size(k: i64) -> i64
called by 1: main