Talk:Conversion between quaternions and Euler angles

Needs to be explicit that this rotates a body
I was looking for the euler 123 to quaternion conversion that will rotate from one frame to another. The euler to quaternion conversion shown on the page does not line up with the SpinCalc euler 123 conversion from Matlab Central. Maybe the equation on the page rotates the points in a body while keeping the reference frame the same?

From SpinCalc.m with scalar at 4th position Q=[s1.*c2.*c3+c1.*s2.*s3,  c1.*s2.*c3-s1.*c2.*s3,   c1.*c2.*s3+s1.*s2.*c3,   c1.*c2.*c3-s1.*s2.*s3];  —Preceding unsigned comment added by 128.157.160.13 (talk) 22:42, 3 September 2009 (UTC)

Are the "Euler angles" in this article really Tait-Bryan_angles?

Canonical form of quaternion?
The equation presented for conversion from Euler angles to Quaternion has several discontinuities that are not necessarily present in the Quaternions themselves.

For instance, for the Euler angles (0,0,-180) and (0,0,180), the conversion would produce the quaternions (0,0,0,1) and (0,0,0,-1). These refer to the same attitude, but linear interpolation or slerp between them would not work well.

It appears that the proper way to handle this is to compute the cosine of the angle between the quaternions (via the dot product) and if this is less than zero to negate one of the quaternions.

Which definition of the Euler angles is being employed in this page?
Absolutely no mention is given as to which (of the 12 possible) definitions of the Euler angles are being employed in this discussion.

Order of angles specified?
Does the order of rotation (described as "in the order yaw, pitch, roll" in first section) match the matrix given in "Rotation matrices" section? That matrix corresponding to rotation with Euler angles can be given by (Rz (Ry Rx)). Isn't that in the order x,y,z instead? — Preceding unsigned comment added by 144.212.114.62 (talk) 22:25, 2 December 2006 (UTC)

Matrix convention
It should be stated what the convention being used for the rotation matrices is. Is it supposed to be pre-multiplied by a row vector or post-multiplied by a column vector? Icalanise (talk) 23:18, 21 October 2008 (UTC)


 * someone seems to be confused. "The orthogonal matrix (post-multiplying a column vector) corresponding to a clockwise/left-handed rotation by the unit quaternion q=q_0+iq_1+jq_2+kq_3 is given by the inhomogeneous expression"


 * If you are using a column vector then the matrix is on the left of the vector and that would appear to be pre-multiplying,  not post-multiplying.Eregli bob (talk) 12:17, 28 October 2012 (UTC)

Euler Conversion
Is the displayed formula correct? The link in the singularity section (http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToEuler/) displays a different formula ... —Preceding unsigned comment added by 83.171.153.247 (talk) 18:07, 1 March 2009 (UTC)


 * Could this be because the article uses a left-handed rotation (as specified on the paragraph giving the matrix for x-y-z convention rotation) ? I'mt not sure, but I think there are a LOT of different ways to convert quaternions to euler angles. See http://www.cgafaq.info/wiki/Euler_angles_from_matrix for example.
 * Basically, if someone knowledgeable enough could rewrite the part on conversion to discuss the various possibilities, that would be very nice. 81.63.104.6 (talk) 20:22, 8 May 2012 (UTC)

The final matrix in the "Rotation Matrices" section corresonds to "ZYX" ordering, as per page A-11 of the NASA memo in the references; I've verified that the expression for the quaternion conforms to the same convention. — Preceding unsigned comment added by 50.76.20.17 (talk) 22:12, 14 January 2014 (UTC)

The 'source code' for the quaternion-to-Euler angle conversion doesn’t match the vector representation immediately above it. SimonJWright (talk) 16:32, 6 December 2016 (UTC)

Error in Quaternion to Euler Angles Conversion
The Quaternion to Euler Angles Conversion when used with a Quaternion created with Euler Angles to Quaternion Conversion does not provide back the same Euler angles originally used for input. Take for example inputs for creating the quaternion of, if you create a quaternion using the   function and then use the result as input for   the result is. This is likely due to multiple sets of Euler angles satisfying any quaternion, but the page should make that more clear. Drankinatty (talk) 04:27, 11 February 2020 (UTC)


 * The C++ code got the pitch computation wrong it should be:
 * double sinp = std::sqrt(1 + 2 * (q.w * q.y - q.x * q.z))
 * double cosp = std::sqrt(1 - 2 * (q.w * q.y - q.x * q.z))
 * Rather than:
 * double sinp = std::sqrt(1 + 2 * (q.w * q.x - q.y * q.z));
 * double cosp = std::sqrt(1 - 2 * (q.w * q.x - q.y * q.z)); Rfspadaro (talk) 18:20, 5 January 2023 (UTC)

Matrices and handedness
The matrices given are for left-handed systems, whereas the drawing uses a right-handed convention. There is no way a beginner in the field can make sense of what is explained. Sam Hocevar (talk) 11:21, 30 April 2012 (UTC)

== This should be updated because normally the diagrams are supporting the conversation and instead they are directly opposite of what the article is discussing. Would be better if this article was written in right handed notation since that is the most common and the pictures kept.

The reference does not exist anymore!
As above — Preceding unsigned comment added by 128.2.176.70 (talk) 16:16, 11 June 2013 (UTC)

If someone needs a quaternion-to-Euler method that actually seems to work,...
...then check this out.

http://bediyap.com/programming/convert-quaternion-to-euler-rotations/ [dead] --> https://web.archive.org/web/20210410215436/http://bediyap.com/programming/convert-quaternion-to-euler-rotations/

I haven't checked if it works, and I don't know the usage rights or licenses that apply to it (if any), but it accounts for multiple sets of Euler angles and it actually tells you which math goes with which set, so it's already better than this article by a mile. 108.3.188.161 (talk) 01:48, 22 July 2014 (UTC)

Sign of pitch angle
In the second figure, showing the Tait-Bryant angles for an aircraft,  the upwards pitch is labelled in the figure as negative theta. This pitch angle would be positive, it is counter-clockwise if you were remotely located on the aircraft's Y axis sticking out of its right wing direction.Lathamibird (talk) 07:10, 2 June 2015 (UTC)

Euler Magic Squares
It says in the introduction Euler used quaternions for Magic squares. This seems unlikely as the math is completely unrelated. Can somebody figure out if there is some way this is true and maybe fix the link?

This page says it deals with JPL quaternions, and I think it's not quite right
At the beginning of the section Definition, it's written "For the rest of this article, the "passive" JPL quaternion convention shall be used." There are two problems with this:

1) I don't think this is right, both the rotation matrix and the quaternion product formulas seem to be consistent with Hamilton matrices instead.

2) The page Quaternions and spatial rotation makes very valid points on why Hamilton quaternions should be favored, so using only Hamilton quaternions here should be preferred. Ebernardes (talk) 14:31, 18 December 2022 (UTC)

Changed the quaternion to Euler angles conversion formula
This new one has no numerical problems for the pitch. For anyone interested, I'll leave here a simple Python snippet that test both expressions to show they are equivalent:

Ebernardes (talk) 16:41, 18 December 2022 (UTC)

---

, I think you are referring to this revision you made, right?: https://en.wikipedia.org/w/index.php?title=Conversion_between_quaternions_and_Euler_angles&diff=1128143523&oldid=1128124788

And I think in your code above,  is the new code, and   was the old calculation, right? What are the problems with ? Why is using  better? Also, you have a typo I believe: it should be. You have  mistakenly where   goes. --ERCaGuy (talk) 03:55, 12 October 2023 (UTC)


 * Hey there @ERCaGuy, thank you for your interest! Indeed, there is a typo! But since I did the same typo twice it still passed the test: the important where was to numerically show that, for our values, $$\arcsin(2 \sigma) = 2 \arctan2(1 + 2 \sigma, 1 - 2\sigma) - \pi/2$$ for some value of $$\sigma$$.
 * As to why this is arguably better, there was an explanation but it was removed in this edit: https://en.wikipedia.org/w/index.php?title=Conversion_between_quaternions_and_Euler_angles&oldid=1128353649.
 * Basically, $$\arcsin, \arccos$$ are not as numerically well-behaved as $$\arctan2$$, which is why we used this version when I updated the transformation code in https://scipy.org/. This is, in my opinion, still not the best version, as this needs the quaternion to be normalized beforehand and the (because of the summation with 1, etc).
 * If you're interested, I showed how to get these equations on this open access paper: https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0276302. Moreover, apart from Scipy, I also implemented it on Sympy, which can be useful if you want to play with the equations symbolically. Ebernardes (talk) 06:51, 12 October 2023 (UTC)
 * Just a heads-up though: the first definitions on this paper have sadly a mistake, and I still didn't manage to make the editors correct it... Ebernardes (talk) 06:51, 12 October 2023 (UTC)


 * @Ebernardes, thank you for all of the responses and links! This is helpful. For anyone wishing to have some Python code to use and test, here is my quaternions_to_euler_angles.py Python program from my eRCaGuy_hello_world repo. I test both techniques. See functions  and  . I run unit tests on them both too.  — Preceding unsigned comment added by ERCaGuy (talk • contribs) 16:24, 19 October 2023 (UTC)
 * @ERCaGuy I'm glad I could help! If you're interested, you can find my implementation of the general method in my repo.
 * Moreover, in the SciPy implementation there are also two implemented conversion methods: an older one from matrix to angles, and the one I published from quaternions directly to angles. The former is not used anymore, except for the unit tests: we wanted to make absolutely sure that the new conversions gave the same answers. Ebernardes (talk) 07:40, 20 October 2023 (UTC)

Cleanup
This article reads like a stream of consciousness university lecture, rather than a Wikipedia article. I personally find the inclusion of sample code to be particularly out of place, but the POV of the article is really strange as well. I recommend that it be cleaned up. TimeEngineer (talk) 13:52, 28 January 2024 (UTC)