mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-04-13 11:30:40 +02:00
36 lines
765 B
Lua
36 lines
765 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
|
|
Public.round = math.round
|
|
|
|
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
|
|
|
|
return Public
|