private float clampMag ( float value , float absMin , float absMax ) { final float absValue = Math . abs ( value ) ; if ( absValue < absMin ) return 0 ; if ( absValue > absMax ) return value > 0 ? absMax : - absMax ; return value ; }
Clamp the magnitude of value for absMin and absMax . If the value is below the minimum it will be clamped to zero . If the value is above the maximum it will be clamped to the maximum .