Fmath API
Functions
Section titled “Functions”MaxFixed
Section titled “MaxFixed”MaxFixed() -> fixed
Returns the maximum value a fixedpoint integer can take.
RandomFixed
Section titled “RandomFixed”RandomFixed(fixed min, fixed max) -> fixed
Returns a random fixedpoint value in the range [min
, max
]. max
must be greater or equal to min
.
RandomNumber
Section titled “RandomNumber”RandomNumber(number min, number max) -> number
Returns an integer in the range [min
, max
]. max
must be greater or equal to min
.
Sqrt(fixed x) -> fixed
Returns the square root of x
. x
must be greater or equal to 0.
FromFraction
Section titled “FromFraction”FromFraction(number numerator, number denominator) -> fixed
Returns the fixedpoint value representing the fraction numerator
/denominator
. denominator
must not be equal to zero.
ToNumber
Section titled “ToNumber”ToNumber(fixed value) -> number
Returns the integral part of the value
.
AbsFixed
Section titled “AbsFixed”AbsFixed(fixed value) -> fixed
Returns the absolute value.
ToFixed
Section titled “ToFixed”ToFixed(number value) -> fixed
Returns a fixedpoint value with the integral part of value
, and no fractional part.
Sincos
Section titled “Sincos”Sincos(fixed angle) -> (fixed, fixed)
Returns the sinus and cosinus of angle
. angle
is in radian.
Atan2(fixed y, fixed x) -> fixed
Returns the principal value of the arc tangent of y/x. Returns a value in the range [0, 2π[.
Tau() -> fixed
Returns τ (aka 2π).