wake function

(double, double, double, double) wake(
  1. double x,
  2. double y,
  3. double vx,
  4. double vy,
  5. double age,
  6. double v,
  7. double k, [
  8. double g = 0,
])

Position and screen velocity after age seconds in the frame of a projectile flying right at v px/s, with drag k (1/s) and gravity g.

Implementation

(double, double, double, double) wake(
  double x,
  double y,
  double vx,
  double vy,
  double age,
  double v,
  double k, [
  double g = 0,
]) {
  final e = math.exp(-k * age);
  final f = (1 - e) / k;
  final vt = g / k;
  return (
    x + vx * f - v * age,
    y + vt * age + (vy - vt) * f,
    vx * e - v,
    vt + (vy - vt) * e,
  );
}