nx_acceleration.nx
buildroot/runtime/nx_acceleration.nx
about
nx_acceleration.nx -- 3D acceleration vector + Newton's second-law
composition with nx_force. Layer 1 physics per
[[feedback-engineering-sciences-bits-up-3d-print-first]].
Unit: Q14 metres-per-second² (m/s²). 1 Q14 unit = 1/16384 m/s²
= 61 µm/s². Range fits i64 to ±5e14 m/s² -- vastly exceeds any
engineering use (rocket sled peaks ~50g ≈ 490 m/s², centrifuge
~10⁶ m/s²).
Newton's second law composition (F = ma):
nx_force_from_mass_accel(mass_kg_q14, accel) -> *NxForce
This is the second cross-primitive composition demo in the
physics layer (after nx_torque_from_position_force). Verified
by smoke roundtrip: gravity acceleration × 1 kg produces the
same NxForce as nx_force_gravity_on_kg(1 kg) within Q14
rounding.
Composes:
nx_force (for F = ma return type)
nx_isqrt (magnitude via Q28 sum-of-squares)
nx_i128 /
nx_muldiv_i64 (overflow protection)
Per [[feedback-four-pillar-design-aware-response]] (META-CARDINAL):
all multi-line subtractions use named temporaries (Pillar 2
recommendation for the nishilang-multi-line-binop gotcha). All
value transforms use let-immutable + pure helpers (no inline
`if x < 0 { x = 0 - x }` -- composes nx_abs if needed).
license_tier: ORIGINAL
dependencies 4 imports · 1 importers
imports: nx_syscalls.nxnx_isqrt.nxnx_i128.nxnx_force.nx
imported by: nx_acceleration_test.nx
structs
| 56 | struct NxAcceleration |
consts
| 37 | const NX_ACCEL_Q14: i64 = 16384 |
| 41 | const NX_ACCEL_GRAVITY_EARTH_Q14: i64 = 160665 |
| 45 | const NX_ACCEL_OK: i64 = 0 |
| 46 | const NX_ACCEL_ERR_NULL_INPUT: i64 = 1 |
| 62 | const NX_ACCEL_BYTES: i64 = 24 |
functions
| 48 | func nx_acceleration_verdict_name(v: i64) -> *u8 called by 1: main |
| 66 | func nx_acceleration_new(ax_q14: i64, ay_q14: i64, az_q14: i64) -> *NxAcceleration |
| 74 | func nx_acceleration_zero() -> *NxAcceleration |
| 80 | func nx_acceleration_g_earth() -> *NxAcceleration |
| 87 | func nx_acceleration_add(a: *NxAcceleration, b: *NxAcceleration) -> *NxAcceleration |
| 93 | func nx_acceleration_sub(a: *NxAcceleration, b: *NxAcceleration) -> *NxAcceleration calls 1: nx_acceleration_new |
| 99 | func nx_acceleration_scale(a: *NxAcceleration, scalar_q14: i64) -> *NxAcceleration |
| 107 | func nx_acceleration_magnitude_q14(a: *NxAcceleration) -> i64 |
| 125 | func nx_force_from_mass_accel(mass_kg_q14: i64, |