diff --git a/modules/quat.lua b/modules/quat.lua index dc22564..4a0e852 100644 --- a/modules/quat.lua +++ b/modules/quat.lua @@ -131,7 +131,7 @@ function quaternion.unit() end function quaternion:to_axis_angle() - if self.w > 1 then + if self.w > 1 or self.w < -1 then self = self:normalize() end @@ -139,13 +139,6 @@ 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