[algo] Drop math functions (moved to mathx)
This commit is contained in:
parent
37779954f9
commit
d1d452f19f
15
algo.lua
15
algo.lua
|
@ -5,25 +5,10 @@
|
||||||
-- @author Lorenzo Cogotti
|
-- @author Lorenzo Cogotti
|
||||||
|
|
||||||
local floor = math.floor
|
local floor = math.floor
|
||||||
local min, max = math.min, math.max
|
|
||||||
|
|
||||||
local algo = {}
|
local algo = {}
|
||||||
|
|
||||||
|
|
||||||
--- Clamp x within range [a,b] (where b >= a).
|
|
||||||
--
|
|
||||||
-- @number x value to clamp.
|
|
||||||
-- @number a interval lower bound (inclusive).
|
|
||||||
-- @number b interval upper bound (inclusive).
|
|
||||||
-- @treturn number clamped value.
|
|
||||||
function algo.clamp(x, a, b) return min(max(x, a), b) end
|
|
||||||
|
|
||||||
--- Sign function.
|
|
||||||
--
|
|
||||||
-- @number x value whose sign should be returned.
|
|
||||||
-- @treturn number sign of x, -1 if negative, 1 if positive, 0 otherwise.
|
|
||||||
function algo.sign(x) return x > 0 and 1 or x < 0 and -1 or 0 end
|
|
||||||
|
|
||||||
--- Fast remove from array.
|
--- Fast remove from array.
|
||||||
--
|
--
|
||||||
-- Replace 'array[i]' with last array's element and
|
-- Replace 'array[i]' with last array's element and
|
||||||
|
|
Loading…
Reference in New Issue