code wiki / (root) / nx_gcode_arc_test.nx

nx_gcode_arc_test.nx

buildroot/runtime/nx_gcode_arc_test.nx

4090 B103 linesdepth 10pulls 23 transitivereach 0 importersview sourcekind gate/prooftopic gcode
docsdependenciesstructsconstsfunctions

about

nx_gcode_arc_test.nx -- verify arc-fit detection + G2/G3 emission. Test polygon: 4 vertices on a unit circle at 0°/90°/180°/270°: (1, 0), (0, 1), (-1, 0), (0, -1) [in Q14: 16384, 0, etc] All on circle centered at (0, 0) radius 1. Expected with arc_fit_enabled: - emitter walks polygon - prev_x=16384, prev_y=0 - tries arc through (16384,0), (0,16384), (-16384,0) - circle center (0,0) ok - extends with (0,-16384) -- on circle, fits - emits single G3 (or G2) from (16384,0) to (0,-16384) - closes loop back to (16384,0) with one G1 So output should contain "G3 X" (or "G2 X") string. With arc_fit_enabled=0 (default), output contains only "G1" moves (no "G2" or "G3"). Closed-form invariants: (a) Default disabled: emit produces NO G2/G3 (b) Setter enables -> setter returns 0 (c) Setter rejects out-of-range -> returns -1 (d) Enabled emit on circle-polygon -> output contains "G3 X" (e) Enabled emit on square (4 collinear-ish points NOT on circle) -> output still works; may or may not emit G3 (square IS a degenerate 4-pt-on-circle inscribed in a circle, so could arc-fit -- skip strict check for v1) expect_exit: 0 license_tier: ORIGINAL

dependencies 6 imports · 0 importers

nx_syscalls.nx nx_polygon.nx nx_slice_contour.nx nx_machine_graph.nx nx_material_profile.nx nx_gcode_emit.nx nx_gcode_arc_test.nx

imports: nx_syscalls.nxnx_polygon.nxnx_slice_contour.nxnx_machine_graph.nxnx_material_profile.nxnx_gcode_emit.nx

imported by: nobody (leaf or entry point)

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

main nx_machine_graph_qidi_xmax nx_machine_graph_alloc sys_mmap nx_material_profile_generi nx_material_profile_alloc sys_mmap ↻ nx_polygon_alloc sys_mmap ↻ nx_polygon_add_vert nx_polygon_set_vert nx_polygon_vert_ptr nx_gemit_new sys_mmap ↻ nx_gcex_filament_xsect_q14 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 nx_gemit_polygon nx_polygon_get_x nx_polygon_vert_ptr ↻ nx_polygon_get_y nx_polygon_vert_ptr ↻ nx_gemit_travel_to nx_gemit_retract nx_gemit_cstr nx_gemit_byte nx_gemit_q14 sys_mmap ↻ nx_q14_to_decimal nx_int_to_decimal nx_gemit_bytes nx_gemit_byte ↻ nx_gemit_int

structs

none

consts

41const Q14: i64 = 16384

functions

43func smoke_contains(buf: *u8, len: i64, needle: *u8) -> i64
called by 1: main
61func main() -> i64