Skip to content

vehicle-dynamics-4

Choose a tag to compare

@lamb2k lamb2k released this 22 Nov 18:44
· 38 commits to main since this release
46cd07f

The engine force carried in Q(16+n): a build-time scale for the vehicle step's force constants.

  • Change: SH2Z_VD_FORCE_FRAC (16 to 28, default 16) sets the fraction bits of the engine force constants (force_low, force_slide, force_high, top_force) and the body's accel_force. A constant such as 0.10027 is no longer rounded to a multiple of 2^-16. Above 16 the force chain runs in int64 with one rounding per product (ties up, saturating to int32), and the force added to the acceleration is converted to Q16 once, at the force application.
  • Compatibility: at the default 16 all 51 SH-2 objects of saturn/src are byte-identical to the previous main's (checked on the CI artifacts: every library object, libsh2zam.a and every model ELF identical). The caller's constants must use the scale the library is built with.
  • Evidence: HOST: vehicle_force_exact, 134,467 checks under GCC, Clang and ASan/UBSan: 200,000 random states against a long-double oracle (error at most 2.7 force steps and 1.5 acceleration steps against bounds of 5 and 2), exact stored constants, saturation, and the negative controls. CI on the merged head passes (host, SH-2 cross compile with the libc check, math lab, docs). No console run and no instruction-model capture. Validation record.
  • Merge: PR #77, merge 46cd07f.
  • Guide: saturn/VEHICLE_DYNAMICS.md.