math

v0.1.6
randomSeed(seed);

Set a random seed

Arguments

seedThe seed value

Returns

numberThe random value

See randomSeed in lu5_math.h
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
See random in lu5_math.h
round(x);

Round a number to the nearest integer

Arguments

xThe value to round

Returns

intThe rounded value

See round in lu5_math.h
floor(x);

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

Arguments

xThe value to floor

Returns

intgreatest integer less than or equals to x

See floor in lu5_math.h
ceil(x);

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

Arguments

xThe value to floor

Returns

intThe floored value

See ceil in lu5_math.h
min(a, b);

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

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
See min in lu5_math.h
max(a, b);

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

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
See max in lu5_math.h
abs(x);

Returns the absolute value of x
see here

Arguments

xThe input value

Returns

numberThe absolote value of the input

See abs in lu5_math.h
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

See map in lu5_math.h
dist();

Calculates the distance between 2 points in 2D or 3D space

dist(x1, y1, x2, y2);

Arguments

x1The x coordinate of the first point
y1The y coordinate of the first point
x2The x coordinate of the second point
y2The y coordinate of the second point
dist(x1, y1, z1, x2, y2, z2);

Arguments

x1The x coordinate of the first point
y1The y coordinate of the first point
z1The y coordinate of the first point
x2The x coordinate of the second point
y2The y coordinate of the second point
z2The z coordinate of the second point
dist(v1, v2);

Arguments

v1The first vector
v2The second vector

Returns

numberThe distance between the points

local d = dist(0, 0, 3, 4);
print(d) -- 5
See dist in lu5_math.h
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

See constrain in lu5_math.h
sin(x);

Sine function (Trigonometry)

Arguments

xThe input value

Returns

numberThe output value

See sin in lu5_math.h
cos(x);

Cosine function (Trigonometry)

Arguments

xThe input value

Returns

numberThe output value

See cos in lu5_math.h
tan(x);

Tangent function (Trigonometry)

Arguments

xThe input value

Returns

numberThe output value

See tan in lu5_math.h
PIConstant

No description

See PI in lu5_math.h
TWO_PIConstant

No description

See TWO_PI in lu5_math.h
HALF_PIConstant

No description

See HALF_PI in lu5_math.h
QUARTER_PIConstant

No description

See QUARTER_PI in lu5_math.h