0
$\begingroup$

in my Programm i am calculating Quaternions in Euler Angles. My values for pitch and roll are from -180 to +180, my yaw values are from -90 to +90. Thats how i do my calculation.

            double pitchYawRollZ = (double)Math.Atan2(2*Y*W + 2*X*Z, 1 - 2*Y*Y - 2*Z*Z);      // roll
            double pitchYawRollY = (double)Math.Atan2(2*X*W + 2*Y*Z, 1 - 2*X*X - 2*Z*Z);      // pitch
            double pitchYawRollX = (double)Math.Asin(2*X*Y + 2*Z*W);                          // yaw

            pitchYawRollZ = pitchYawRollZ * (180 / Math.PI);
            pitchYawRollY = pitchYawRollY * (180 / Math.PI);
            pitchYawRollX = pitchYawRollX * (180 / Math.PI);

Is there something wrong or why isn't my yaw just so wierd. I also got one more question. I got 4 different values in my quaternion. I get these quaternions from a Sensor and the values are jumping a little bit.

0,65564     -0,125366   -0,67804    -0,307739
0,65564     -0,125305   -0,67804    -0,307678
0,65564     -0,125244   -0,67804    -0,307678
0,655701    -0,125244   -0,67804    -0,307617
0,655701    -0,125183   -0,678101   -0,307556
0,655701    -0,125122   -0,678101   -0,307556
0,655762    -0,125122   -0,678101   -0,307495

My sensor is not moving but i got this little difference. Can i calculate this difference in angles?

$\endgroup$
  • $\begingroup$ Are you asking why the formula for yaw looks different from the pitch and roll formulae? If that's so, you can see similar formulae, and helpful links, in the answers to this question but be aware that there's a host of different conventions for the angles, which leads to various different versions of the formulae with different signs etc. Otherwise, you may need to clarify your question. $\endgroup$ – user575517 Jul 26 '18 at 16:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.