March Docs

Arcade.Physics.Gesture

Types

typeTrackPointTrackPoint = { gt : Float, gx : Float, gy : Float }#

A time with an x and a y: positions, then velocities, then accelerations.

typeGestureLimitsGestureLimits = {#

When a flick counts, and the windows it is read over (seconds, and points per second along y).

typeGestureMetricsGestureMetrics = {#

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

fndiffdiff(xs : List(TrackPoint)) : List(TrackPoint) needs ()#
fnflipflip(xs : List(TrackPoint)) : List(TrackPoint) needs ()#

fn smooth(xs : List(TrackPoint)) : List(TrackPoint) needs () do smooth_go([], xs, []) end

fnlast_at_or_beforelast_at_or_before(first : TrackPoint, points : List(TrackPoint), t : Float) : TrackPoint needs ()#

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

fnmean_or_zeromean_or_zero(sum : Float, xs : List(TrackPoint)) : Float needs ()#
fnmeasuremeasure(points : List(TrackPoint), lim : GestureLimits) : Option(GestureMetrics) needs ()#
fnregression_at_endregression_at_end(tail : List(TrackPoint), last_v : TrackPoint, end_t : Float) : Float needs ()#

A least-squares line through tail's y against time, read at end_t. With fewer than two points, last_v's y.

fnstart_timestart_time(v : List(TrackPoint), peak : Float, fraction : Float, fallback : Float) : Float needs ()#

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

fnsum_tsum_t(xs : List(TrackPoint)) : Float needs ()#
fnsum_xsum_x(xs : List(TrackPoint)) : Float needs ()#
fnsum_ysum_y(xs : List(TrackPoint)) : Float needs ()#