math

Contains functions which Figura adds to the default Lua "math" library table

math.map

Maps the given value from one range to another
For example,
if you have a value of 20 in the range 0-200, and you want to map it to the range 100-200, the result will be 110
overload 1:
math.map(value, oldMin, oldMax, newMin, newMax)
Method Property Fluent Description Representation
value accepts a Number
oldMin accepts a Number
oldMax accepts a Number
newMin accepts a Number
newMax accepts a Number
Return Value a Number

math.round

Rounds the given number to the nearest whole integer
overload 1:
math.round(value)
Method Property Fluent Description Representation
value accepts a Number
Return Value a Number

math.sign

Returns the sign of the given number
Returns 1 if the number is positive,
-1 if it's negative, and 0 if it's 0
overload 1:
math.sign(value)
Method Property Fluent Description Representation
value accepts a Number
Return Value a Number

math.lerp

Linearly interpolates from its first argument to its second argument, with the third argument as the parameter
Works on both regular numbers,
vectors of the same type, and matrices of the same type
overload 1:
math.lerp(a, b, t)
Method Property Fluent Description Representation
a accepts a Number
b accepts a Number
t accepts a Number
Return Value a Number
overload 2:
math.lerp(a, b, t)
Method Property Fluent Description Representation
a accepts a Vector
b accepts a Vector
t accepts a Number
Return Value a Vector

math.lerpAngle

Similar to the default lerp function, but numbers are limited to the range of 0-360
Lerp is done towards the shortest angle
For example,
a lerp of 340 and 20, with a factor of 0.75, will return 10
overload 1:
math.lerpAngle(a, b, t)
Method Property Fluent Description Representation
a accepts a Number
b accepts a Number
t accepts a Number
Return Value a Number

math.shortAngle

Returns the shortest angle between two angles
For example,
if you have an angle of 350 degrees and you want to get the shortest angle between it and 0 degrees, the result will be 10 degrees
overload 1:
math.shortAngle(from, to)
Method Property Fluent Description Representation
from accepts a Number
to accepts a Number
Return Value a Number

math.clamp

Clamps the given value between min and max
overload 1:
math.clamp(value, min, max)
Method Property Fluent Description Representation
value accepts a Number
min accepts a Number
max accepts a Number
Return Value a Number
a a