code wiki / _hdl_build / nx_geo_buffer.nx
nx_geo_buffer.nx
buildroot/runtime/_hdl_build/nx_geo_buffer.nx
about
nx_geo_buffer.nx -- LIB: GEO-017 BUFFER / OFFSET MEASURE (Minkowski sum of a convex polygon with a
disk of radius r). For a CONVEX polygon the buffered area has the exact closed form
area(P (+) disk_r) = area(P) + perimeter(P)*r + pi*r^2
(the straight edges sweep rectangles of total area perimeter*r; the corners sweep wedges that sum to
one full disk pi*r^2). We compute this MEASURE in integer arithmetic, doubled to match GEO-010:
buffer_area2 = geo_area2(P) + 2*perimeter*r + 2*pi*r^2, 2*pi*r^2 ~ 710*r^2/113 (pi ~ 355/113).
HONEST SCOPE: this returns the buffer COVERAGE MEASURE (doubled microdeg^2), not the rounded buffer
BOUNDARY polygon. It is DETERMINISTIC integer arithmetic; the only inexactness is pi via the 355/113
rational (error ~2.7e-7) and nx_isqrt's floor on non-perfect-square edge lengths -- no float drift.
This is the "expand a geofence by R meters" coverage query. Convention: poly = flat [lat0,lon0,...],
r in the same microdeg units. license_tier: ORIGINAL
dependencies 3 imports · 1 importers
imports: nx_geo_area.nxnx_isqrt.nxnx_syscalls.nx
imported by: nx_geo_buffer_gate.nx
structs
| none |
consts
| none |
functions
| 18 | func geo_perimeter(poly: *i64, npts: i64) -> i64 |
| 33 | func geo_buffer_area2(poly: *i64, npts: i64, r: i64) -> i64 |