nx_polygon_test.nx
buildroot/runtime/nx_polygon_test.nx
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
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
structs
| none |
consts
| 33 | const Q14_ONE: i64 = 16384 |
functions
| 35 | func main() -> i64 |