math
v0.0.5randomSeed(seed);
Set a random seed
Arguments
seed
The seed valueReturns
number
The random valuerandom(min, max);
Get a random number
Arguments
min
The minimum of the rangemax
The maximum of the rangeReturns
number
The random value random() -- random number between 0 and 1
random(3) -- random number between 0 and 3
random(3, 12) -- random number between 3 and 12
random({ 'A', 'B', 'C' }) -- random element in table
round(x);
Round a number to the nearest integer
Arguments
x
The value to roundReturns
int
The rounded valuefloor(x);
see here floor is a function that takes in a number, and returns the greatest integer less or equal to x
Arguments
x
The value to floorReturns
int
greatest integer less than or equals to xceil(x);
see here ceil is a function that takes in a number, and returns the smallest integer greater or equal to x
Arguments
x
The value to floorReturns
int
The floored valuemin(a, b);
Can also take any number of arguments, or a table. Return the smallest value.
Arguments
a
The first valueb
The second valueReturns
number
The smallest value min(6, 7); -- returns 6
min(6, 7, 4); -- returns 4
min({ 6, 7, 4 }); -- returns 4
max(a, b);
Can also take any number of arguments, or a table. Return the largest value.
Arguments
a
The first valueb
The second valueReturns
number
The largest value max(2, 5); -- returns 5
max(2, 5, 7); -- returns 7
max({ 2, 5, 7 }); -- returns 7
abs(x);
see here Returns the absolute value of x which is its distance from 0
Arguments
x
The input valueReturns
number
The absolote value of the inputmap(x, s1, e1, s2, e2);
Maps x from an original range to a target range
Arguments
x
The value to maps1
The start of the initial rangee1
The end of the initial ranges2
The start of the target rangee2
The end of the target rangeReturns
number
The mapped valuedist(x1, y1, x2, y1);
Calculates the distance between 2 points in 2D space
Arguments
x1
The x coordinate of the first pointy1
The y coordinate of the first pointx2
The x coordinate of the second pointy1
The y coordinate of the second pointReturns
number
The distance between the pointsconstrain(x, min, max);
Limits x to a minimum and maximum value
Arguments
x
The input valuemin
The minimum valuemax
The maximum valueReturns
number
The constrained valuesin(x);
Sine function (Trigonometry)
Arguments
x
The input valueReturns
number
The output valuecos(x);
Cosine function (Trigonometry)
Arguments
x
The input valueReturns
number
The output valuetan(x);
Tangent function (Trigonometry)
Arguments
x
The input valueReturns
number
The output valuePI
GlobalTWO_PI
GlobalHALF_PI
GlobalQUARTER_PI
Global