rigz.math: Functions Modinfo Source  

Math module for general math functions

Functions Summary

AngleDifference Get the difference between 2 angles.
GetDirection get the direction from 1 point to another.
GetDistance The distance between 1 point and another.
GetNearestPowerOf2 Round up to the nearest power of 2.
GetTexSize Gets the texture size needed for an animation with a given size and number of frames.
Round rounds a number to the nearest int.
TweenValues Interpolate between 2 values.

Functions

Function AngleDifference:Float(Angle1:Float, Angle2:Float)
DescriptionGet the difference between 2 angles.

Function GetDirection:Float(fromx:Float, fromy:Float, tox:Float, toy:Float)
ReturnsAngle of difference.
Descriptionget the direction from 1 point to another.
InformationThanks to "Snarkbait" for this little code snippit.

Function GetDistance:Float(fromx:Float, fromy:Float, tox:Float, toy:Float, fast:Int = False)
ReturnsThe distance between the 2 points.
DescriptionThe distance between 1 point and another.

Function GetNearestPowerOf2:Int(n:Int)
DescriptionRound up to the nearest power of 2.

Function GetTexSize(w:Int, h:Int, frames:Int, powersof2:Int = True, texwidth:Int Var, texheight:Int Var, Cols:Int Var, rows:Int Var)
Returnsthe texture width and height, along with the number of columns and rows of animation frames.
DescriptionGets the texture size needed for an animation with a given size and number of frames.
Informationthis function will ensure that the texture width and height remain in powers of 2.

Function Round:Int(v:Double)
ReturnsRounded Int.
Descriptionrounds a number to the nearest int.

Function TweenValues:Float(oldValue:Float, value:Float, tween:Float)
DescriptionInterpolate between 2 values.
InformationThis is the function used to achieve render tweening by taking the old and new values and interpolating between the 2.

Module Information

AuthorPeter J. Rigby
CopyrightPeter J. Rigby 2009
PurposeA General Math Module
Versionv1