topical media & game development

talk show tell print [swf] [flash] flex

  package be.nascom.util{
          public class @ax-graphic-player-10-cube-be-nascom-util-MathFunctions{
                  public static const PI_180:Number=Math.PI/180;
                  public static const ONE80_PI:Number=180/Math.PI;
                  public static function radiansToDegrees(rad:Number):Number{
                          return rad*ONE80_PI;
                  public static function degreesToRadians(degree:Number):Number{
                          return degree*PI_180;
                  public static function getRandomNumberInRange(min:Number,max:Number):Number{
                          return min+Math.random()*(max-min);
                  public static function getRandomIntInRange(min:int,max:int):int{
                          return Math.round(min+Math.random()*(max-min));
                  public static function getRandomUintInRange(min:uint,max:uint):uint{
                          return uint(Math.round(min+Math.random()*(max-min)));
                  //ripped off from bit-101
          public static function normalize(value:Number, minimum:Number, maximum:Number):Number{
              return (value - minimum) / (maximum - minimum);
          public static function interpolate(normValue:Number, minimum:Number, maximum:Number):Number{
              return minimum + (maximum - minimum) * normValue;
          public static function map(value:Number, min1:Number, max1:Number, min2:Number, max2:Number):Number{
              return interpolate( normalize(value, min1, max1), min2, max2);

(C) Æliens 04/09/2009

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.