Added some missing math functions from lua

This commit is contained in:
EvilFactory
2023-03-03 17:26:53 -03:00
parent 27cde50c08
commit d9789b8438
3 changed files with 24 additions and 2 deletions
@@ -0,0 +1,21 @@
math.lerp = function (a, b, t)
return a * (1 - t) + b * t
end
math.clamp = function (value, min, max)
return math.max(min, math.min(max, value))
end
math.round = function (value, decimals)
decimals = decimals or 0
local mult = 10 ^ decimals
return math.floor(value * mult + 0.5) / mult
end
math.sign = function (value)
return value >= 0 and 1 or -1
end
math.remap = function (value, inMin, inMax, outMin, outMax)
return outMin + (outMax - outMin) * ((value - inMin) / (inMax - inMin))
end