qc.Math

Description

Extens the class of Math. This class represents a singleton object that can be accessed directly as game.math.

Method

Method Description
fuzzyEqual Two number are fuzzyEqual if their difference is less than epsilon
fuzzyLessThan a is fuzzyLessThan b if it is less than b + epsilon
fuzzyGreaterThan a is fuzzyGreaterThan b if it is more than b - epsilon
fuzzyCeil ceiling(val-epsilon)
fuzzyFloor floor(val-epsilon)
shuffle Shuffles the data in the given array into a new order.
average Averages all values passed to the function and returns the result.
shear n mod 1
snapTo Snap a value to nearest grid slice, using rounding.
snapToFloor Snap a value to nearest grid slice, using floor.
snapToCeil Snap a value to nearest grid slice, using ceil.
roundTo Round to some place comparative to a base, default is 10 for decimal place. The place is represented by the power applied to base to get that place.
floorTo Floor to some place comparative to a base, default is 10 for decimal place.
ceilTo Ceil to some place comparative to a base, default is 10 for decimal place.
angleBetween Find the angle of a segment from (x1, y1) -> (x2, y2).
angleBetweenY Note that the difference between this method and Math.angleBetween is that this assumes the y coordinate travels down the screen.
normalizeAngle Normalizes an angle to the [0,2pi) range.
reverseAngle Reverses an angle.
maxAdd Adds the given amount to the value, but never lets the value go over the specified maximum.
minSub Subtracts the given amount from the value, but never lets the value go below the specified minimum.
wrap Ensures that the value always stays between min and max, by wrapping the value around.
wrapValue Adds value to amount and ensures that the result always stays between 0 and max, by wrapping the value around.
wrapAngle Keeps an angle value between -180 and +180; or -PI and PI if radians.
isOdd Returns true if the number given is odd.
isEven Returns true if the number given is even.
min Variation of Math.min that can be passed either an array of numbers or the numbers as parameters.
max Variation of Math.max that can be passed either an array of numbers or the numbers as parameters.
linear Calculates a linear (interpolation) value over t.
factorial Calculates a factorial value .
getRandom Fetch a random entry from the given array.
distance Returns the euclidian distance between the two given set of coordinates.
clamp Force a value within the boundaries by clamping x to the range [a, b].
within Checks if two values are within the given tolerance of each other.
sign A value representing the sign of the value: -1 for negative, +1 for positive, 0 if value is 0.
degToRad Convert degrees to radians.
radToDeg Convert radians to degrees.
random Returns a random real number between min and max
uuid Returns a unique string
id Returns next cookie
invert Invert matrix
multiply Matrix multiply
smoothDamp Smooth damping