update method
Sets the motion to a specific point in time. The t
value that is passed
in is a normalized value 0.0 to 1.0 of the duration of the motion. Every
motion will always recieve a callback with the end time point (1.0),
unless it is cancelled.
Implementation
@override
void update(double t) {
int p;
double lt;
if (t < 0.0) t = 0.0;
if (t >= 1.0) {
p = points.length - 1;
lt = 1.0;
} else {
p = (t / _dt).floor();
lt = (t - _dt * p) / _dt;
}
Offset p0 = points[(p - 1).clamp(0, points.length - 1)];
Offset p1 = points[(p + 0).clamp(0, points.length - 1)];
Offset p2 = points[(p + 1).clamp(0, points.length - 1)];
Offset p3 = points[(p + 2).clamp(0, points.length - 1)];
Offset newPos = _cardinalSplineAt(p0, p1, p2, p3, tension, lt);
setter(newPos);
}