From 951aea865fefe1f4ff671ee9b18d94c167ad5353 Mon Sep 17 00:00:00 2001 From: Colby Klein Date: Mon, 14 Sep 2015 13:33:44 -0700 Subject: [PATCH] Proper fix for the quat.to_axis_angle bug. Apparently, I was getting a number so close to -1 (but just under) that it just printed as -1. Fuck off. --- modules/quat.lua | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) 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