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.
This commit is contained in:
parent
18dd29d1b5
commit
951aea865f
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user