I believe the math.atan function is incorrectly calculating (or not considering) the two argument version of math.atan(y,x).
I was able to restore functionality for my project using this replacement but this is probably not optimized, wanted to post this here so others could use it since its pretty common in game-dev 2D/3D vector math:
local oldatan = math.atan
function math.atan(y,x)
if(x==nil)then return oldatan(y) end
if(x>0)then return oldatan(y/x) end
if(x<0 and y >= 0)then return oldatan(y/x) + math.pi end
if(x<0 and y < 0)then return oldatan(y/x) - math.pi end
if(x==0 and y>0)then return math.pi/2 end
if(x==0 and y<0)then return -math.pi/2 end
return nil
end
print(math.atan(1)," 0.78539816339745 (π/4)")
print(math.atan(0)," 0")
print(math.atan(-1)," -0.78539816339745 (-π/4)")
print(math.atan(1, 1)," 0.78539816339745 (π/4)")
print(math.atan(1, 0)," 1.5707963267949 (π/2)")
print(math.atan(-1, 0)," -1.5707963267949 (-π/2)")
I believe the math.atan function is incorrectly calculating (or not considering) the two argument version of
math.atan(y,x).I was able to restore functionality for my project using this replacement but this is probably not optimized, wanted to post this here so others could use it since its pretty common in game-dev 2D/3D vector math: