x method
The position of the object in the simulation at the given time.
Implementation
@override
double x(double time) {
if (startValue.isNaN) return endValue;
if (startValue == endValue) return startValue;
double normalizedTime = time / duration;
double normalizedVelocity =
startVelocity / (endValue - startValue) * duration;
double normalizedOutput = normalizedVelocity > 2
? linearAccelerationEaseInOutWithInitialVelocity(
normalizedTime, normalizedVelocity)
: constantAccelerationEaseInOutWithInitialVelocity(
normalizedTime, normalizedVelocity);
return startValue + normalizedOutput * (endValue - startValue);
}