easeFactor function

double easeFactor(
  1. double rate,
  2. double dt
)

How much of the way to a target one step of dt seconds should carry, for something that eases in at rate per second.

1 - exp(-rate * dt), which was written out at six call sites across four packages — two cameras, a suspension, a weapon's bob, the loop's own interpolation and its pace meter.

Not rate * dt, and the difference is the whole reason this is a function. A plain multiply is a spring whose stiffness depends on the frame rate: the same camera lags differently at 60 and at 144, and past rate * dt > 1 it overshoots and rings. This form is the exact solution of the same easing over the step, so a machine that drops frames gets the same motion as one that does not — which is the property the whole fixed step exists to protect.

A rate of nought never moves; a negative one is treated as nought rather than as a body flying apart.

Implementation

double easeFactor(double rate, double dt) {
  if (rate <= 0.0 || dt <= 0.0) return 0.0;
  return 1.0 - Portable.exp(-rate * dt);
}