private float limit(float value,float min,float max){
  return Math.min(Math.max(min,value),max);
}

private float limit ( float value , float min , float max ) { return Math . min ( Math . max ( min , value ) , max ) ; }
limits the value to the given min and max range .
