Arcade.Physics.Gesture
Types
A time with an x and a y: positions, then velocities, then accelerations.
When a flick counts, and the windows it is read over (seconds, and points per second along y).
What measure read from a flick it accepted. Speeds are upward; accel_up and accel_side are the mean acceleration over the closing window, and norm_jerk is the RMS jerk scaled by duration squared over peak speed.
Functions
fn smooth(xs : List(TrackPoint)) : List(TrackPoint) needs () do smooth_go([], xs, []) end
fn rms_jerk(jf : List(TrackPoint)) : Float needs () do if List.is_empty(jf) do 0.0 else Math.sqrt(List.fold_left(jf, 0.0, fn (acc, e) -> acc +. e.gy . e.gy +. e.gx . e.gx) /. count(jf)) end end
A least-squares line through tail's y against time, read at end_t. With fewer than two points, last_v's y.
fn fastest(v0 : TrackPoint, xs : List(TrackPoint)) : TrackPoint needs () do List.fold_left(xs, v0, fn (best, e) -> if best.gy < e.gy do e else best end) end
fn last_of(v0 : TrackPoint, xs : List(TrackPoint)) : TrackPoint needs () do List.fold_left(xs, v0, fn (_, e) -> e) end