Work around math.acos(-1) returning NaN on LuaJIT... sometimes.

This commit is contained in:
Colby Klein 2015-09-14 13:26:05 -07:00
parent 6a5771348c
commit 18dd29d1b5

View File

@ -139,6 +139,13 @@ function quaternion:to_axis_angle()
local s = math.sqrt(1-self.w*self.w)
local x, y, z
-- HACK: Why the fuck is this ever NaN?
-- I suspect a LuaJIT optimization bug - it doesn't happen in the repl.
if angle ~= angle then
angle = math.pi * 2
s = 0
end
if s < constants.FLT_EPSILON then
x = self.x
y = self.y