ExponentialDecay.halfLife constructor

ExponentialDecay.halfLife(
  1. Duration t, {
  2. double endVelocity = 60,
})

Velocity half-life — the time for velocity to halve.

Implementation

factory ExponentialDecay.halfLife(Duration t, {double endVelocity = 60}) {
  final s = t.inMicroseconds / 1e6;
  if (s <= 0) return ExponentialDecay.none(endVelocity: endVelocity);
  return ExponentialDecay(
    1 - math.pow(0.5, 1 / s).toDouble(),
    endVelocity: endVelocity,
  );
}