math

v0.0.5
randomSeed(seed);

Set a random seed

Arguments

seedThe seed value

Returns

numberThe random value


random(min, max);

Get a random number

Arguments

minThe minimum of the range
maxThe maximum of the range

Returns

numberThe 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

xThe value to round

Returns

intThe rounded value


floor(x);

see here floor is a function that takes in a number, and returns the greatest integer less or equal to x

Arguments

xThe value to floor

Returns

intgreatest integer less than or equals to x


ceil(x);

see here ceil is a function that takes in a number, and returns the smallest integer greater or equal to x

Arguments

xThe value to floor

Returns

intThe floored value


min(a, b);

Can also take any number of arguments, or a table. Return the smallest value.

Arguments

aThe first value
bThe second value

Returns

numberThe 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

aThe first value
bThe second value

Returns

numberThe 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

xThe input value

Returns

numberThe absolote value of the input


map(x, s1, e1, s2, e2);

Maps x from an original range to a target range

Arguments

xThe value to map
s1The start of the initial range
e1The end of the initial range
s2The start of the target range
e2The end of the target range

Returns

numberThe mapped value


dist(x1, y1, x2, y1);

Calculates the distance between 2 points in 2D space

Arguments

x1The x coordinate of the first point
y1The y coordinate of the first point
x2The x coordinate of the second point
y1The y coordinate of the second point

Returns

numberThe distance between the points


constrain(x, min, max);

Limits x to a minimum and maximum value

Arguments

xThe input value
minThe minimum value
maxThe maximum value

Returns

numberThe constrained value


sin(x);

Sine function (Trigonometry)

Arguments

xThe input value

Returns

numberThe output value


cos(x);

Cosine function (Trigonometry)

Arguments

xThe input value

Returns

numberThe output value


tan(x);

Tangent function (Trigonometry)

Arguments

xThe input value

Returns

numberThe output value


PIGlobal


TWO_PIGlobal


HALF_PIGlobal


QUARTER_PIGlobal