dx method

  1. @override
double dx(
  1. double time
)
override

The velocity of the object in the simulation at the given time.

Implementation

@override
double dx(double time) {
  if (startValue.isNaN) return 0.0;
  if (startValue == endValue) return 0.0;
  final normalizedTime = time / duration;
  final normalizedVelocity =
      startVelocity / (endValue - startValue) * duration;
  final normalizedOutput = normalizedVelocity > 2
      ? _velocityOfLinearAccelerationEaseInOutWithInitialVelocity(
          normalizedTime,
          normalizedVelocity,
        )
      : _velocityOfConstantAccelerationEaseInOutWithInitialVelocity(
          normalizedTime,
          normalizedVelocity,
        );
  return normalizedOutput * (endValue - startValue) / duration;
}