v1.2.0.1-beta1
|
Math Object Extensions
Public Member Functions | |
number | clamp (number value, number min, number max) |
number | constrain (number value, number min, number max) |
number | roundTo (number value, number precision) |
number | toDegrees (number radians) |
number | toRadians (number degrees) |
number | percentOfRange (number percentValue, number rangeMin, number rangeMax) |
number | rangeValueToPercent (number value, number rangeMin, number rangeMax) |
number clamp | ( | number | value, |
number | min, | ||
number | max | ||
) |
Constrain value
between min
and max
values.
number constrain | ( | number | value, |
number | min, | ||
number | max | ||
) |
Alias for Math.clamp()
number roundTo | ( | number | value, |
number | precision | ||
) |
Round value
to precision
decimal places.
number toDegrees | ( | number | radians | ) |
Convert radians
to degrees.
number toRadians | ( | number | degrees | ) |
Convert degrees
to radians.
number percentOfRange | ( | number | percentValue, |
number | rangeMin, | ||
number | rangeMax | ||
) |
Scales percentValue
into the numeric range specified by rangeMin
and rangeMax
and returns the new value. In other words, "what value does this percentage represent within this range." This may return a value outside the given range if percentValue
is greater or less than 100. percentValue
is always treated as absolute.
Either of rangeMin
or rangeMax
can be the larger number. The returned value will be proportional in either case.
number rangeValueToPercent | ( | number | value, |
number | rangeMin, | ||
number | rangeMax | ||
) |
Returns the percentage of the rangeMin
through rangeMax
numeric range represented by value
. In other words, "what percentage does this value represent of the given range." This may return a percentage greater than 100 if value
falls outside of rangeMin
and rangeMax
.
Either of rangeMin
or rangeMax
can be the larger number. The returned percentage will be proportional in either case.