1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-02-05 13:15:03 +02:00
danielmartin0 2bd92f7008 math fixes
2024-10-03 23:23:12 +01:00

44 lines
916 B
Lua

local Public = {}
-- Importing localized math functions from this file has better performance than importing from the global scope:
Public.random = math.random
Public.randomseed = math.randomseed
Public.sqrt = math.sqrt
Public.min = math.min
Public.max = math.max
Public.rad = math.rad
Public.floor = math.floor
Public.abs = math.abs
Public.ceil = math.ceil
Public.log = math.log
Public.atan = math.atan
Public.sin = math.sin
Public.cos = math.cos
Public.pi = math.pi
Public.deg = math.deg
function Public.clamp(number, min, max)
if number < min then
return min
elseif number > max then
return max
else
return number
end
end
function Public.sgn(number)
return number > 0 and 1 or (number == 0 and 0 or -1)
end
function Public.round(num, idp)
local mult = 10 ^ (idp or 0)
return math.floor(num * mult + 0.5) / mult
end
function math.round(num, idp)
return Public.round(num, idp)
end
return Public