Content deleted Content added
m Signing comment by 50.76.20.17 - "→Euler Conversion: " |
Ebernardes (talk | contribs) |
||
(30 intermediate revisions by 21 users not shown) | |||
Line 1:
{{WikiProject banner shell|class=Start|
{{WikiProject Mathematics|priority=low}}
}}
{{Old merge full|otherpage=Charts on SO(3)|date=August 30, 2011|result=No Consensus|talk=Talk:Charts on SO(3)#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?
Line 19 ⟶ 24:
==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.
I agree. This seems to be using the Tait-Brain (or whatever spelling) convention.
This one here is the standard: https://hepweb.ucsd.edu/ph110b/110b_notes/node36.html . It uses the sequence z-y-z, with notation phi, theta, psi.
We can easily verify that the formulas given on this page are wrong for that standard, by computing omega once from phi,theta,psi and their derivatives, and once from the quaternion q as per the presented formula her, and its derivative dq.
This article is frustrating because it pretends a hands-on appeal ("just pick up the equations and use them for your project") when in fact they are plainly incorrect. I only noticed it when GPT pointed me to where it came up with those inconclusive equations; so you are doing a lot of damage here. I propose we pull this article offline until it is correct and verified to be correct. And since we can verify correctness of algebra, I would suggest we go ahead and do this for all Wikipedia articles that feature any formulas. <!-- Template:Unsigned IP --><small class="autosigned">— Preceding [[Wikipedia:Signatures|unsigned]] comment added by [[Special:Contributions/31.17.92.45|31.17.92.45]] ([[User talk:31.17.92.45#top|talk]]) 11:21, 29 October 2024 (UTC)</small> <!--Autosigned by SineBot-->
:Totally agree, this page does not make much sense.
:I personally think this page should be scrapped, condensed to a little section called "conversion between ZYX Tait-Bryan angles and quaternions" that only gives out the equations, explains why this sequence is being given particular interest (because it's the most used) and then add it to the main page called [[Quaternions and spatial rotation]].
:This would be MUCH less confusing, in my opinion, and still gives the formula in a "just pick up the equations and use them for your project" way, albeit more explicitly. [[User:Ebernardes|Ebernardes]] ([[User talk:Ebernardes|talk]]) 11:44, 29 October 2024 (UTC)
== Order of angles specified? ==
Line 37 ⟶ 54:
: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. [[Special:Contributions/81.63.104.6|81.63.104.6]] ([[User talk: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. <span style="font-size: smaller;" class="autosigned">— Preceding [[Wikipedia:Signatures|unsigned]] comment added by [[Special:Contributions/50.76.20.17|50.76.20.17]] ([[User talk:50.76.20.17|talk]]) 22:12, 14 January 2014 (UTC)</span><!-- Template:Unsigned IP --> <!--Autosigned by SineBot-->
The 'source code' for the quaternion-to-Euler angle conversion doesn’t match the vector representation immediately above it. [[User:SimonJWright|SimonJWright]] ([[User talk: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 <code>roll = 180, pitch = 90, yaw = 45</code>, if you create a quaternion using the <code>ToQuaternion()</code> function and then use the result as input for <code>ToEulerAngles()</code> the result is <code>roll = 180, pitch = 90, yaw = 26.565</code>. This is likely due to multiple sets of Euler angles satisfying any quaternion, but the page should make that more clear. [[User:Drankinatty|Drankinatty]] ([[User talk: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)); [[User:Rfspadaro|Rfspadaro]] ([[User talk: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. [[User:Sam Hocevar|Sam Hocevar]] ([[User talk: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 <span style="font-size: smaller;" class="autosigned">— Preceding [[Wikipedia:Signatures|unsigned]] comment added by [[Special:Contributions/128.2.176.70|128.2.176.70]] ([[User talk:128.2.176.70|talk]]) 16:16, 11 June 2013 (UTC)</span><!-- Template:Unsigned IP --> <!--Autosigned by SineBot-->
== If someone needs a quaternion-to-Euler method that actually seems to work,... ==
...then check this out.
<s>http://bediyap.com/programming/convert-quaternion-to-euler-rotations/</s> [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. [[Special:Contributions/108.3.188.161|108.3.188.161]] ([[User talk: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.[[User:Lathamibird|Lathamibird]] ([[User talk: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. [[User:Ebernardes|Ebernardes]] ([[User talk: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:
<syntaxhighlight lang="python">
import numpy as np
from itertools import product
for w, x, y, z in product([-1, 0, 1], repeat=4):
n = np.sqrt(w**2 + x**2 + y**2 + z**2)
if n > 10e-7:
w /= n
x /= n
y /= n
z /= n
sinp = np.sqrt(1 + 2 * (w * x - y * z));
cosp = np.sqrt(1 - 2 * (w * x - y * z));
pitch1 = 2 * np.arctan2(sinp, cosp) - np.pi / 2;
pitch2 = np.arcsin(2 * (w * x - y * z))
assert (pitch1 - pitch2) < 10e-7
</syntaxhighlight>[[User:Ebernardes|Ebernardes]] ([[User talk:Ebernardes|talk]]) 16:41, 18 December 2022 (UTC)
---
{{reply to|Ebernardes}}, 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, <code>pitch1</code> is the new code, and <code>pitch2</code> was the old calculation, right? What are the problems with <code>pitch2</code>? Why is using <code>pitch1</code> better? Also, you have a typo I believe: it should be <code>pitch2 = np.arcsin(2*(w*y - z*x))</code>. You have <code>w*x</code> mistakenly where <code>w*y</code> goes.
--[[User:ERCaGuy|ERCaGuy]] ([[User talk:ERCaGuy|talk]]) 03:55, 12 October 2023 (UTC)
:Hey there @[[User:ERCaGuy|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, <math>\arcsin(2 \sigma) = 2 \arctan2(1 + 2 \sigma, 1 - 2\sigma) - \pi/2</math> for some value of <math>\sigma</math>.
: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, <math>\arcsin, \arccos</math> are not as numerically well-behaved as <math>\arctan2</math>, 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. [[User:Ebernardes|Ebernardes]] ([[User talk: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... [[User:Ebernardes|Ebernardes]] ([[User talk:Ebernardes|talk]]) 06:51, 12 October 2023 (UTC)
:: @[[User:Ebernardes|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 [https://github.com/ElectricRCAircraftGuy/eRCaGuy_hello_world/blob/master/python/quaternions_to_euler_angles.py quaternions_to_euler_angles.py] Python program from my [https://github.com/ElectricRCAircraftGuy/eRCaGuy_hello_world eRCaGuy_hello_world] repo. I test both techniques. See functions <code>quaternion2euler()</code> and <code>quaternion2euler2()</code>. I run unit tests on them both too. <!-- Template:Unsigned --><small class="autosigned">— Preceding [[Wikipedia:Signatures|unsigned]] comment added by [[User:ERCaGuy|ERCaGuy]] ([[User talk:ERCaGuy#top|talk]] • [[Special:Contributions/ERCaGuy|contribs]]) 16:24, 19 October 2023 (UTC)</small> <!--Autosigned by SineBot-->
:::@[[User:ERCaGuy|ERCaGuy]] I'm glad I could help! If you're interested, you can find my implementation of the general method [https://github.com/evbernardes/quaternion_to_euler 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. [[User:Ebernardes|Ebernardes]] ([[User talk: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. [[User:TimeEngineer|TimeEngineer]] ([[User talk:TimeEngineer|talk]]) 13:52, 28 January 2024 (UTC)
:I totally agree that this is a strange page. I do not really have the time to attempt rewriting it, but I'm up for helping with the math if a rewrite is ever done. [[User:Ebernardes|Ebernardes]] ([[User talk:Ebernardes|talk]]) 13:35, 29 August 2024 (UTC)
|