easeValVel function
Implementation
(double, double) easeValVel(
double startValue,
double endValue,
double startTime,
double endTime,
double currentTime,
double initialVelocity,
) {
if (startTime == double.negativeInfinity || startValue == endValue) {
return (endValue, 0.0);
}
double normalizedTime = (currentTime - startTime) / (endTime - startTime);
double normalizedVelocity =
initialVelocity / (endValue - startValue) * (endTime - startTime);
late double normalizedPOut, normalizedVelOut;
if (normalizedVelocity > 2) {
normalizedPOut = linearAccelerationEaseInOutWithInitialVelocity(
normalizedTime, normalizedVelocity);
normalizedVelOut = velocityOfLinearAccelerationEaseInOutWithInitialVelocity(
normalizedTime, normalizedVelocity);
} else {
normalizedPOut = constantAccelerationEaseInOutWithInitialVelocity(
normalizedTime, normalizedVelocity);
normalizedVelOut =
velocityOfConstantAccelerationEaseInOutWithInitialVelocity(
normalizedTime, normalizedVelocity);
}
return (
startValue + normalizedPOut * (endValue - startValue),
normalizedVelOut * (endValue - startValue) / (endTime - startTime),
);
}