combineVelocity method

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

Combines line velocity with inVelocity based on velocityRatio.

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;
}