code wiki / (root) / nx_gcode_extrude.nx

nx_gcode_extrude.nx

buildroot/runtime/nx_gcode_extrude.nx

6218 B142 linesdepth 4pulls 5 transitivereach 48 importersview sourcekind librarytopic gcode
docsdependenciesstructsconstsfunctions

about

nx_gcode_extrude.nx -- extrusion-distance math for FDM G-code. Computes how many millimetres of filament must be fed for a given XY move at given line width + layer height to satisfy volume conservation (incompressible deposit): extruded_volume_mm3 = line_width_mm * layer_height_mm * move_length_mm filament_cross_section = π * (filament_radius_mm)^2 E_delta_mm = extruded_volume_mm3 / filament_cross_section Per cardinal feedback-engineering-sciences-bits-up-3d-print-first: this primitive is MATH (geometric volume) + PHYSICS (continuity equation: mass-in == mass-out for incompressible flow). Future physics refinements where this composes: - Rheology: shear-rate-dependent viscosity (PLA at 210°C), pressure-drop through nozzle, max sustainable flow rate - Thermal: melt-zone heat budget bounding max_flow_mm3s - Material science: glass-transition temperature gating bridge fan timing All of those would refine THIS primitive's outputs. v1 ships the volume-conservation core; further physics queued. Coordinate convention: Q14 fixed-point throughout (1 unit = 1/16384). Reusability: this primitive is also valid for CNC paste extruders, food printers, concrete printers, bioprinters -- anywhere a moving nozzle deposits a controlled volume per unit length. Hence runtime/ (multi-purpose), not nishi-print/ (3D-print-specific) hub. Numerical robustness: - Uses nx_isqrt for move-length computation (no float sqrt). - Uses nx_muldiv_i64 for intermediate products that would overflow plain i64 (filament_xsect computation can reach 2^44). license_tier: ORIGINAL

dependencies 3 imports · 4 importers

nx_syscalls.nx nx_isqrt.nx nx_i128.nx nx_gcode_extrude.nx nx_estimate.nx nx_gcode_emit.nx nx_gcode_emit_test.nx nx_gcode_extrude_test.nx

imports: nx_syscalls.nxnx_isqrt.nxnx_i128.nx

imported by: nx_estimate.nxnx_gcode_emit.nxnx_gcode_emit_test.nxnx_gcode_extrude_test.nx

structs

none

consts

41const NX_PI_Q14: i64 = 51472 // π × 16384, rounded
42const NX_GCEX_Q14_ONE: i64 = 16384
46const NX_GCEX_OK: i64 = 0
47const NX_GCEX_ERR_BAD_GEOMETRY: i64 = 1
48const NX_GCEX_ERR_BAD_FILAMENT: i64 = 2

functions

50func nx_gcex_verdict_name(v: i64) -> *u8
70func nx_gcex_filament_xsect_q14(filament_dia_um: i64) -> i64
89func nx_gcex_move_length_q14(x1: i64, y1: i64, x2: i64, y2: i64) -> i64
116func nx_gcex_E_delta_q14(line_width_q14: i64, layer_height_q14: i64,
136func nx_gcex_E_delta_for_move(x1: i64, y1: i64, x2: i64, y2: i64,