code wiki / _hdl_build / nx_geo_clip.nx

nx_geo_clip.nx

buildroot/runtime/_hdl_build/nx_geo_clip.nx

4577 B96 linesdepth 2pulls 2 transitivereach 3 importersview sourcekind librarytopic geo
docsdependenciesstructsconstsfunctions

about

nx_geo_clip.nx -- LIB: GEO-015 POLYGON INTERSECTION (Sutherland-Hodgman convex clip). THE EXCEED ANGLE (measured, not asserted): the inside/outside classification of every vertex against every clip edge is the SIGN of an INTEGER cross product -- ZERO floating point, so the topology of the result (which vertices survive, where edges cross) is EXACT and DETERMINISTIC. That is the part float clippers (Turf/PostGIS) get wrong on touching/collinear edges. HONEST SCOPE: the intersection VERTEX itself is S + (E-S)*dS/(dS-dE) computed in integer arithmetic and ROUNDED to microdegrees -- deterministic-integer, NOT exact-rational geometry. To stay overflow-safe at any scale the fraction (num,den) is normalized (shifted down in lockstep) before the multiply, since (E-S)*dS would otherwise exceed i64 at continental scale; the ratio is preserved to sub-microdegree. Convention (matches nx_geo): polygons = flat [lat0,lon0, ...], lat=Y, lon=X. The CLIP polygon must be CONVEX and CCW. Writes the clipped polygon to out (caller sizes it >= (ns+nc+8) vertices); returns the output vertex count (0 = no overlap). license_tier: ORIGINAL

dependencies 1 imports · 2 importers

nx_syscalls.nx nx_geo_clip.nx nx_geo_clip_gate.nx nx_geo_union.nx

imports: nx_syscalls.nx

imported by: nx_geo_clip_gate.nxnx_geo_union.nx

structs

none

consts

16const K_MAGIC_17179869184: i64 = 17179869184

functions

18func geo_cabs(x: i64) -> i64 { if x < 0 { return 0 - x } return x }
called by 1: geo_intersect_into
21func geo_clip_inside(ax: i64, ay: i64, bx: i64, by: i64, px: i64, py: i64) -> i64
called by 1: geo_poly_clip
29func geo_intersect_into(buf: *i64, pos: i64, sx: i64, sy: i64, ex: i64, ey: i64, ax: i64, ay: i64, bx: i64, by: i64) -> i64
called by 1: geo_poly_clip calls 1: geo_cabs
50func geo_poly_clip(subj: *i64, ns: i64, clip: *i64, nc: i64, out: *i64) -> i64