Log inGet started
Package

crashRig.package

This package holds more than this page lists. See all of its files in its world.

README.md

measure

Crash-test signal processing as pure functions, with no engine state. The CrashRig component calls it to turn probe samples into readouts, and any game that measures accelerations can call it the same way.

  • channel() collects {t, g} samples, keeping time strictly increasing.
  • resample(ch, dt) puts a channel on a uniform grid (the rig uses 1 kHz).
  • cfc(x, dt, class) is the SAE J211/1 channel-class filter: a two-pole Butterworth low-pass run forward and backward (zero phase). Head channels use CFC 1000, chest CFC 180, the car pulse CFC 60.
  • peak(x) returns the largest value.
  • hic(a, dt, window) is the Head Injury Criterion; window = 0.015 gives HIC15.
  • clip3ms(a, dt) is the highest level the signal holds for a cumulative 3 ms.
  • decimate(x, dt, n) shrinks a trace to at most n points, keeping peaks, for a synced result.
  • rate(result) gives Euro NCAP-style bands (good / acceptable / marginal / poor) for head, chest and structure, plus 0–5 stars:
    • head: HIC15 500 / 700 / 1000, or the 3 ms clip at 72 / 80 / 88 g, whichever is worse;
    • chest: 3 ms clip at 38 / 48 / 60 g;
    • structure: crush as a share of the crush zone's travel, 0.70 / 0.85 / 0.97.
local M = require("crashRig.measure")
local ch = M.channel()
for _, s in Physics.motionSamples(headId, "head") do ch:add(s.time, s.g) end
local u = M.resample(ch, 1 / 1000)
local f = M.cfc(u.g, u.dt, 1000)
print(M.peak(f), M.hic(f, u.dt, 0.015), M.clip3ms(f, u.dt))