sample method

double sample(
  1. double time
)

Normalized progress, exactly 1 when complete. Evaluate motion and completion together so they cannot disagree or repeat the exponential. Stop when remaining progress and predicted one-frame travel are both at most 0.01%, independent of color distance/model and getter frequency.

Implementation

double sample(double time) {
  final start = _start;
  if (start == null) return 1;
  final x = _omega * math.max(0.0, time - start);
  final decay = math.exp(-x);
  final remaining = (1 + x) * decay;
  return remaining <= 0.0001 && _omega * x * decay / 60 <= 0.0001
      ? 1
      : 1 - remaining;
}