From 250438dfe90385446ddc27c5f824e87c5e00d84e Mon Sep 17 00:00:00 2001 From: Sei Lisa Date: Mon, 23 Jan 2017 16:41:56 +0100 Subject: [PATCH] Simplify the llRot2Euler equations. We save a few multiplications by dividing both atan2 arguments by 2. --- lslopt/lslbasefuncs.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lslopt/lslbasefuncs.py b/lslopt/lslbasefuncs.py index 1b0cab1..3c285ed 100644 --- a/lslopt/lslbasefuncs.py +++ b/lslopt/lslbasefuncs.py @@ -1584,14 +1584,14 @@ def llRot2Euler(r): # Check gimbal lock conditions if abs(y) > 0.99999: - return Vector(F32((0., math.asin(y), math.atan2(2.*(r[2]*r[3]+r[0]*r[1]), - 1.-2.*(r[0]*r[0]+r[2]*r[2]))))) + return Vector(F32((0., math.asin(y), math.atan2(r[2]*r[3]+r[0]*r[1], + .5-(r[0]*r[0]+r[2]*r[2]))))) qy2 = r[1]*r[1] return Vector(F32(( - math.atan2(2.*(r[0]*r[3]-r[1]*r[2]), 1.-2.*(r[0]*r[0]+qy2)), + math.atan2(r[0]*r[3]-r[1]*r[2], .5-(r[0]*r[0]+qy2)), math.asin(y), - math.atan2(2.*(r[2]*r[3]-r[0]*r[1]), 1.-2.*(r[2]*r[2]+qy2)) + math.atan2(r[2]*r[3]-r[0]*r[1], .5-(r[2]*r[2]+qy2)) ))) def llRot2Fwd(r):