2018-09-28 18:42:36 +02:00
|
|
|
local _sin = math.sin
|
|
|
|
local _cos = math.cos
|
2018-09-28 16:26:50 +02:00
|
|
|
|
|
|
|
math.sin = function(x)
|
2018-09-28 18:42:36 +02:00
|
|
|
return math.floor(_sin(x) * 10000000 + 0.5) / 10000000
|
2018-09-28 16:26:50 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
math.cos = function(x)
|
2018-09-28 18:42:36 +02:00
|
|
|
return math.floor(_cos(x) * 10000000 + 0.5) / 10000000
|
2018-09-28 16:26:50 +02:00
|
|
|
end
|
2018-10-02 10:08:57 +02:00
|
|
|
|
2018-10-04 17:56:49 +02:00
|
|
|
-- rounds number (num) to certain number of decimal places (idp)
|
|
|
|
math.round = function(num, idp)
|
|
|
|
local mult = 10 ^ (idp or 0)
|
|
|
|
return math.floor(num * mult + 0.5) / mult
|
|
|
|
end
|
|
|
|
|
|
|
|
math.clamp = function(num, min, max)
|
|
|
|
if num < min then
|
|
|
|
return min
|
|
|
|
elseif num > max then
|
|
|
|
return max
|
|
|
|
else
|
|
|
|
return num
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2018-10-02 10:08:57 +02:00
|
|
|
math.sqrt2 = math.sqrt(2)
|
2018-10-02 23:53:05 +02:00
|
|
|
math.inv_sqrt2 = 1 / math.sqrt2
|
2018-11-06 13:55:52 +02:00
|
|
|
math.tau = 2 * math.pi
|
2018-10-02 10:08:57 +02:00
|
|
|
return math
|