mirror of
https://github.com/Refactorio/RedMew.git
synced 2024-12-12 10:04:40 +02:00
Round math.sin instead of approximating it
This commit is contained in:
parent
b94f65ba51
commit
646d050dd0
@ -1,20 +1,11 @@
|
||||
local tau = 2 * math.pi
|
||||
local half_pi = math.pi / 2
|
||||
local _sin = math.sin
|
||||
local _cos = math.cos
|
||||
|
||||
math.sin = function(x)
|
||||
local sign = 1
|
||||
x = (x / tau * 360) % 360
|
||||
if x < 0 then
|
||||
x = - x
|
||||
sign = - sign
|
||||
end
|
||||
if x > 180 then sign = - sign end
|
||||
x = x % 180
|
||||
if x == 0 then return 0 end
|
||||
local a = x * (180 - x)
|
||||
return sign * 4 * a / (40500 - a)
|
||||
return math.floor(_sin(x) * 10000000 + 0.5) / 10000000
|
||||
end
|
||||
|
||||
|
||||
math.cos = function(x)
|
||||
return math.sin(x + half_pi)
|
||||
return math.floor(_cos(x) * 10000000 + 0.5) / 10000000
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user