code wiki / _hdl_build / nx_geo_haversine.nx

nx_geo_haversine.nx

buildroot/runtime/_hdl_build/nx_geo_haversine.nx

3311 B57 linesdepth 6pulls 7 transitivereach 1 importersview sourcekind librarytopic geo
docsdependenciesstructsconstsfunctions

about

nx_geo_haversine.nx -- LIB: GEO-003b GREAT-CIRCLE distance (haversine), the PRECISION REFINEMENT of GEO-003 equirectangular. Hardware-up + DRY: REUSES the sovereign CORDIC sin/cos (fx.nx, Q16.16), the vectoring-mode CORDIC atan2 (geo_atan2 from nx_geo_query), and nx_isqrt -- no trig reinvention. WHY THIS RUNG (measured, not asserted): equirectangular assumes a locally-flat earth, so its error grows with span -- ~0.5% regionally and several percent at continental / antipodal scale. Haversine is exact great-circle on the reference sphere. The gate PROVES the exceed: for NYC->Sydney (~16000 km) haversine lands within ~2% of the true distance while equirectangular is off by far more -- so haversine is measurably CLOSER. (For short spans GEO-003 stays the right tool: its integer deltas avoid the Q16.16 underflow of a tiny half-angle's sine.) All Q16.16 fixed point -> deterministic. license_tier: ORIGINAL

dependencies 5 imports · 1 importers

nx_geo_query.nx nx_geo_distance.nx fx.nx nx_isqrt.nx nx_syscalls.nx nx_geo_haversine.nx nx_geo_haversine_gate.nx

imports: nx_geo_query.nxnx_geo_distance.nxfx.nxnx_isqrt.nxnx_syscalls.nx

imported by: nx_geo_haversine_gate.nx

structs

none

consts

18const HAV_MAGIC_360000000: i64 = 360000000
19const HAV_MAGIC_180000000: i64 = 180000000
21const HAV_R_M: i64 = 6371000 // mean Earth radius in meters (the great-circle reference sphere)

functions

24func hav_micro_to_q16(micro: i64) -> i64
called by 1: geo_haversine_m
32func geo_haversine_m(lat1: i64, lon1: i64, lat2: i64, lon2: i64) -> i64