code wiki / _hdl_build / nx_geo_segint.nx

nx_geo_segint.nx

buildroot/runtime/_hdl_build/nx_geo_segint.nx

2604 B62 linesdepth 2pulls 2 transitivereach 1 importersview sourcekind librarytopic geo
docsdependenciesstructsconstsfunctions

about

nx_geo_segint.nx -- LIB: GEO-015b SEGMENT-SEGMENT INTERSECTION primitive (the building block for non-convex polygon clipping / Greiner-Hormann, hardening GEO-015/016 toward real boundary polygons). Parametric: P1 + t*(P2-P1) = P3 + u*(P4-P3). With d1=P2-P1, d2=P4-P3, e=P3-P1: denom = cross(d1,d2); t = cross(e,d2)/denom; u = cross(e,d1)/denom. All INTEGER cross products -> the topological classification is EXACT and deterministic: 0 = no intersection (parallel-disjoint, or lines meet outside one of the segments) 1 = proper interior crossing (single point, strictly inside both) 2 = touch at an endpoint (t or u exactly 0 or 1) 3 = collinear (overlapping supports) The intersection POINT (codes 1,2) is written to out2 = [x,y], microdeg-rounded, with the t fraction normalized (lockstep >>1) so P1 + t*d1 can't overflow i64 at any scale (same trick as GEO-015). Generic 2D (caller maps lat/lon as it likes). license_tier: ORIGINAL

dependencies 1 imports · 1 importers

nx_syscalls.nx nx_geo_segint.nx nx_geo_segint_gate.nx

imports: nx_syscalls.nx

imported by: nx_geo_segint_gate.nx

structs

none

consts

15const K_MAGIC_17179869184: i64 = 17179869184

functions

17func geo_si_abs(x: i64) -> i64 { if x < 0 { return 0 - x } return x }
called by 1: geo_seg_intersect
19func geo_seg_intersect(p1x: i64, p1y: i64, p2x: i64, p2y: i64, p3x: i64, p3y: i64, p4x: i64, p4y: i64, out2: *i64) -> i64
called by 1: main calls 1: geo_si_abs