private float applyFriction(float velocity,float simulationRate){
  if (isZero(velocity)) {
    velocity=0.0f;
  }
 else   if (velocity > 0) {
    velocity=Math.max(0.0f,velocity - (FRICTION * simulationRate));
  }
 else {
    velocity=Math.min(0.0f,velocity + (FRICTION * simulationRate));
  }
  return velocity;
}

private float applyFriction ( float velocity , float simulationRate ) { if ( isZero ( velocity ) ) { velocity = 0.0f ; } else if ( velocity > 0 ) { velocity = Math . max ( 0.0f , velocity - ( FRICTION * simulationRate ) ) ; } else { velocity = Math . min ( 0.0f , velocity + ( FRICTION * simulationRate ) ) ; } return velocity ; }
friction slows velocity in the opposite direction of motion , until zero velocity is reached .
