I have not posted in a while, do to finals, vacations and excuses. But for my final I got into algorithmic animation and I used these functions a great deal to help me out. The values must be in the range to work correctly.

// returns a number between 0.0 and 1.0 //
public static function normalize(value:Number, low:Number, high:Number):Number {
   return value/(high + low);
}

// value should always be between 0.0 – 1.0. Places value into desired range of low – high //
public static function lerp(value:Number, low:Number, high:Number):Number {
   return value * (high – low) + low;
}

// convert the value parameter from range low1 to high1 to the range low2 to high2 //
public static function map(value:Number, low1, high1, low2, high2):Number {
   return normalize(value, low1, high1) * (high2 – low2) + low2;
}

// convert radians to degrees //
public static function toDegrees(radians:Number):Number {
   return radians * 180/Math.PI;
}

// convert degrees to radians //
public static function toRadians(degrees:Number):Number {
   return degrees * Math.PI / 180;
}

Download Class