code wiki / (root) / nx_torque_test.nx

nx_torque_test.nx

buildroot/runtime/nx_torque_test.nx

3315 B90 linesdepth 6pulls 7 transitivereach 0 importersview sourcekind gate/proof
docsdependenciesstructsconstsfunctions

about

nx_torque_test.nx -- torque vector ops + cross-primitive composition demo with nx_force. Closed-form invariants (Q14 N·m unless noted): (a) Zero torque magnitude = 0. (b) Unit +Z torque magnitude = Q14. (c) (3, 4, 0) Q14 N·m -> magnitude 5 Q14 (3-4-5). (d) Add: (1, 2, 3) + (4, 5, 6) = (5, 7, 9). (e) τ = r × F demo: r = (1, 0, 0) m, F = (0, 1, 0) N → τ = +Z 1 N·m (right-hand rule). (f) τ = r × F: r = (0, 2, 0) m, F = (3, 0, 0) N → τ = (0*0 - 0*0, 0*3 - 0*0, 2*0 - 0*3 - oh wait Let me recompute by formula: τ_x = r_y*F_z - r_z*F_y = 2*0 - 0*0 = 0 τ_y = r_z*F_x - r_x*F_z = 0*3 - 0*0 = 0 τ_z = r_x*F_y - r_y*F_x = 0*0 - 2*3 = -6 → (0, 0, -6) Q14 N·m (g) τ from r=0, F=anything → zero torque (no lever arm). (h) Verdict name lookup non-NULL for every verdict. expect_exit: 0 license_tier: ORIGINAL

dependencies 3 imports · 0 importers

nx_syscalls.nx nx_force.nx nx_torque.nx nx_torque_test.nx

imports: nx_syscalls.nxnx_force.nxnx_torque.nx

imported by: nobody (leaf or entry point)

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

main nx_torque_zero nx_torque_new sys_mmap nx_torque_magnitude_q14 nx_isqrt nx_torque_new ↻ near nx_torque_add nx_torque_new ↻ nx_force_new sys_mmap ↻ nx_torque_from_position_fo nx_force_new ↻ nx_force_cross 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_force_new ↻ nx_torque_new ↻ nx_torque_verdict_name

structs

none

consts

33const Q14: i64 = 16384

functions

35func near(actual: i64, expected: i64, tol: i64) -> i64
called by 1: main
42func main() -> i64