# Direect angle extraction from quaternion

please forgive my lack of background in math's, but i need to clear up a doubt i have about quaternion and the rotation they express.

my goal is to extract the angle (specifically pitch and roll) the sensor is giving me from a quaternion. I need the angles around its own axis rather than a fixed frame.

given a unit quaterion q = a + bi + cj + dk. Using :

$$pitch = 2sin^{-1}(b) \\ roll = 2sin^{-1}(c) \\ yaw = 2sin^{-1}(d)$$

i can extract the angles but only when the sensor is not rotated around yaw from the starting angle. when i start rotating yaw, everything get wonky.

i am sure i am missing something important, but i need some easy-to-understand tips to get moving.

I have also noticed that if i multiply the rotation quaternion to its conjugate i have a "zeroing" effect on the output.

Thanks

• The answer will very much depend on the rotation order that was used (en.wikipedia.org/wiki/Euler_angles). Do you know which one was used? – Matti P. Jul 15 '20 at 12:35
• Here's also (a bit long, I admit) discussion on a similar question. Please read my answer, it should clarify the computations quite much: math.stackexchange.com/questions/3273597/… – Matti P. Jul 15 '20 at 12:39
• I have searched quite extensively inside the sensor datasheet (BNO080 from Ceva-DSP) but nowhere is clearly said what rotation order was used. I have made some tests with euler conversion, and found that ZYX scheme fit correctly. – gionag Jul 15 '20 at 12:49
• Just to be extra-clear. Given a certain Quaterion, needing rotations around its own axis, i can just go with the atan/asin/atan conversion to extract angles, or in this case i need to manipulate an intermediate quaternion to work with ? – gionag Jul 15 '20 at 12:56
• What do you mean by "angles around its own axis"? What is "it" in this case? – Matti P. Jul 15 '20 at 12:58