combineVelocity method

double combineVelocity(
  1. double inVelocity, {
  2. double velocityRatio = 0.65,
  3. double maxFallOff = 1.0,
})

Combines the line's intrinsic velocity with an inVelocity based on a velocityRatio.

inVelocity The incoming velocity to combine with. velocityRatio The ratio to weigh the line's intrinsic velocity (0.0 to 1.0). maxFallOff The maximum allowed difference between the combined velocity and inVelocity. Returns the combined velocity.

Implementation

double combineVelocity(double inVelocity,
    {double velocityRatio = 0.65, double maxFallOff = 1.0}) {
  final value =
      (_velocity * velocityRatio) + (inVelocity * (1.0 - velocityRatio));

  maxFallOff *= _distance / 10.0;

  final dif = value - inVelocity;
  if (dif.abs() > maxFallOff) {
    if (dif > 0.0) {
      return inVelocity + maxFallOff;
    } else {
      return inVelocity - maxFallOff;
    }
  }

  return value;
}