From bcac1def4c1b459e116ae1957e8ac4e20a7d9192 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 22 Oct 2010 03:27:01 +0000 Subject: eulO_to_quat wasn't functional for XZY, YXZ, ZYX rotation orders. it also modified the input rotation value which isn't expected for these functions. --- source/blender/blenlib/intern/math_rotation.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source/blender/blenlib') diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c index 3b58fe88bf5..09cb02ce56a 100644 --- a/source/blender/blenlib/intern/math_rotation.c +++ b/source/blender/blenlib/intern/math_rotation.c @@ -1083,10 +1083,10 @@ void eulO_to_quat(float q[4],float e[3], short order) double ti, tj, th, ci, cj, ch, si, sj, sh, cc, cs, sc, ss; double a[3]; - ti = e[i]/2; tj = e[j]/2; th = e[k]/2; - - if (R->parity) e[j] = -e[j]; - + ti = e[i] * 0.5f; + tj = e[j] * (R->parity ? -0.5f : 0.5f); + th = e[k] * 0.5f; + ci = cos(ti); cj = cos(tj); ch = cos(th); si = sin(ti); sj = sin(tj); sh = sin(th); @@ -1102,7 +1102,7 @@ void eulO_to_quat(float q[4],float e[3], short order) q[2] = a[1]; q[3] = a[2]; - if (R->parity) q[j] = -q[j]; + if (R->parity) q[j+1] *= -1.0f; } /* Convert quaternion to Euler angles (in radians). */ -- cgit v1.2.3