From 1af60101f2c072b8395bb08563d3a92e1ccce252 Mon Sep 17 00:00:00 2001 From: Lars Mueller Date: Thu, 1 Apr 2021 01:04:59 +0200 Subject: [PATCH] Fix quaternion.to_euler_rotation --- quaternion.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/quaternion.lua b/quaternion.lua index b219ef1..fe497b8 100644 --- a/quaternion.lua +++ b/quaternion.lua @@ -84,16 +84,16 @@ function to_euler_rotation(self) local sinp = 2 * (self[4] * self[2] - self[3] * self[1]) if sinp <= -1 then - rotation.z = -math.pi/2 + rotation.y = -math.pi/2 elseif sinp >= 1 then - rotation.z = math.pi/2 + rotation.y = math.pi/2 else - rotation.z = math.asin(sinp) + rotation.y = math.asin(sinp) end local siny_cosp = 2 * (self[4] * self[3] + self[1] * self[2]) local cosy_cosp = 1 - 2 * (self[2] ^ 2 + self[3] ^ 2) - rotation.y = math.atan2(siny_cosp, cosy_cosp) + rotation.z = math.atan2(siny_cosp, cosy_cosp) return vector.apply(rotation, math.deg) end