code wiki / (root) / nx_gcode_extrude_test.nx

nx_gcode_extrude_test.nx

buildroot/runtime/nx_gcode_extrude_test.nx

3501 B88 linesdepth 5pulls 6 transitivereach 0 importersview sourcekind gate/prooftopic gcode
docsdependenciesstructsconstsfunctions

about

nx_gcode_extrude_test.nx -- extrusion math hand-verified against closed-form physics (volume conservation: mass-in == mass-out for incompressible deposit). Reference computation for a 10mm move at standard 0.4mm width + 0.2mm height + 1.75mm filament: filament_radius = 0.875mm filament_xsect = π × 0.875² = π × 0.765625 ≈ 2.405 mm² extruded_volume = 0.4 × 0.2 × 10 = 0.8 mm³ E_delta = 0.8 / 2.405 ≈ 0.3326 mm of filament In Q14: E_delta ≈ 0.3326 × 16384 ≈ 5451 Q14 units. Closed-form invariants: (a) filament_xsect for 1.75mm dia = 2.405mm² ≈ 39408 Q14. Acceptable tolerance: ±2 Q14 units (rounding in radius+π+r²). (b) move_length for (0,0)->(10,0) = 10mm = 163840 Q14. (c) move_length for (0,0)->(0,10) = 10mm = 163840 Q14. (d) move_length for (3,0)->(0,4) (3-4-5 triangle hypotenuse) = 5mm = 81920 Q14 NOTE: Q14 sqrt has small rounding error; accept ±2. (e) E_delta for the standard move = ~5451 Q14. (f) E_delta scales linearly with move length: 20mm move = 2× E_delta of 10mm move. (g) E_delta is 0 for zero-length move. (h) Zero filament_xsect returns 0 (defensive, not crash). expect_exit: 0 license_tier: ORIGINAL

dependencies 2 imports · 0 importers

nx_syscalls.nx nx_gcode_extrude.nx nx_gcode_extrude_test.nx

imports: nx_syscalls.nxnx_gcode_extrude.nx

imported by: nobody (leaf or entry point)

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

main 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 smoke_near nx_gcex_move_length_q14 nx_isqrt nx_gcex_E_delta_for_move nx_gcex_move_length_q14 ↻ nx_gcex_E_delta_q14 nx_muldiv_i64 ↻

structs

none

consts

33const Q14: i64 = 16384

functions

36func smoke_near(actual: i64, expected: i64, tol: i64) -> i64
called by 1: main
43func main() -> i64