0

I was making a 3d game and wanted to calculate the degree of rotation of the character. I have the quaternion points in (x, y, z, w) format and wanted to convert it to [0-360] angle. I looked at examples of how to do it here on SO and other website too but all I could find was wrong conversion methods and outdated ones. What is the right way to convert quaternion to angle degrees. This website does the conversion but doesn't show the MATH how: quaternion to angle degrees convertor. Any help is appreciated. Thanks in advance

krmogi
  • 2,588
  • 1
  • 10
  • 26
seriously
  • 1,202
  • 5
  • 23
  • 1
    Re, "..all I could find was wrong..." Wrong how? Do you have an example of what you tried? And, how did you know that the result was wrong? – Solomon Slow Oct 30 '21 at 00:17
  • See here: [https://stackoverflow.com/questions/3825571/how-to-convert-quaternion-to-angle](https://stackoverflow.com/questions/3825571/how-to-convert-quaternion-to-angle) – James Tursa Oct 30 '21 at 00:17
  • @JamesTursa the SO link show that 2*cos-1(w) it the convestion method but I read somewhere in SO that mobile phones use an inverse Y wont that affect the conversion because my code is running on PC – seriously Oct 30 '21 at 00:22
  • @SolomonSlow I saw a lot of wrong methods. This is one: https://stackoverflow.com/questions/52584715/how-can-i-convert-a-quaternion-to-an-angle?rq=1 – seriously Oct 30 '21 at 00:23
  • 1
    Did you try this? https://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation#Recovering_the_axis-angle_representation (Note: It's been several years since the last time I did any math with 3-D rotations, and I'm too lazy to dig up my old code right now, so I can't say for sure whether the Wikipedia formula is correct. But @seriously, Did you try it?) – Solomon Slow Oct 30 '21 at 01:16
  • Also, you might consider asking on https://computergraphics.stackexchange.com/ if you don't get good answers here. The best questions to ask here start with "I don't understand this error message..." or "I don't understand why my code... did this weird thing..." – Solomon Slow Oct 30 '21 at 01:27
  • @SolomonSlow Got it thanks – seriously Oct 30 '21 at 01:43
  • 2
    https://threejs.org/docs/?q=vector4#api/en/math/Vector4.setAxisAngleFromQuaternion – WestLangley Oct 30 '21 at 01:44

0 Answers0