code wiki / (root) / nx_polygon_test.nx

nx_polygon_test.nx

buildroot/runtime/nx_polygon_test.nx

5062 B111 linesdepth 5pulls 7 transitivereach 0 importersview sourcekind gate/proof
docsdependenciesstructsconstsfunctions

about

nx_polygon_test.nx -- exercise foundational polygon ops + offset on a CCW unit-mm square. Closed-form invariants on a unit-mm square at (0,0)-(Q14,Q14): (a) Factory yields 4 verts in CCW order. (b) Signed 2*area = 2 * Q14 * Q14 = 2^29 (positive = CCW). (c) is_ccw returns 1. (d) bbox = (0, 0, Q14, Q14). (e) Point inside (8192, 8192) -> 1; outside (-100, 8192) -> 0; outside (32768, 8192) -> 0; outside (8192, -100) -> 0. (f) Orientation predicate: - orient(0,0, Q14,0, 0,Q14) = +1 (CCW) - orient(0,0, 0,Q14, Q14,0) = -1 (CW) - orient(0,0, Q14,0, 2*Q14,0) = 0 (collinear) (g) Segment intersection: - (0,0)-(10K,10K) crosses (0,10K)-(10K,0) -> 1 - (0,0)-(5K,5K) and (6K,6K)-(10K,10K) non-overlapping -> 0 - (0,0)-(Q14,0) and (Q14,0)-(2*Q14,0) touching endpoint -> 0 - parallel non-collinear -> 0 (h) Offset OUTWARD by 0.1mm (1638 Q14): corner (0,0) moves to (-1638,-1638); resulting bbox is (-1638,-1638,18022,18022); polygon remains CCW and area grew. (i) Offset INWARD by 0.1mm (-1638 Q14): corner (0,0) moves to (1638,1638); bbox is (1638,1638,14746,14746); area shrunk. expect_exit: 0 license_tier: ORIGINAL

dependencies 3 imports · 0 importers

nx_syscalls.nx nx_abs.nx nx_polygon.nx nx_polygon_test.nx

imports: nx_syscalls.nxnx_abs.nxnx_polygon.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main nx_polygon_make_square nx_polygon_alloc sys_mmap nx_polygon_add_vert nx_polygon_set_vert nx_polygon_vert_ptr nx_polygon_get_x nx_polygon_vert_ptr ↻ nx_polygon_get_y nx_polygon_vert_ptr ↻ nx_polygon_signed_2area_q2 nx_polygon_get_x ↻ nx_polygon_get_y ↻ nx_polygon_is_ccw nx_polygon_signed_2area_q2 ↻ sys_mmap ↻ nx_polygon_bbox nx_polygon_get_x ↻ nx_polygon_get_y ↻ nx_polygon_point_inside nx_polygon_get_x ↻ nx_polygon_get_y ↻ nx_polygon_orient nx_polygon_segments_cross nx_polygon_orient ↻ nx_polygon_offset nx_polygon_alloc ↻ nx_polygon_get_x ↻ nx_polygon_get_y ↻ nx_isqrt nx_muldiv_i64 nx_i128_alloc nx_i128_mul_i64 nx_i128_mul_u64 nx_i128_neg nx_i128_div_i64 nx_i128_is_neg nx_i128_neg ↻ nx_i128_udiv_u64

structs

none

consts

33const Q14_ONE: i64 = 16384

functions

35func main() -> i64