Talk:Conversion between quaternions and Euler angles: Difference between revisions

Content deleted Content added
ERCaGuy (talk | contribs)
Line 123:
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)