raylib icon indicating copy to clipboard operation
raylib copied to clipboard

Fix: QuaternionFromEuler() and QuaternionToEuler()

Open krysperz2 opened this issue 2 years ago • 1 comments

Fixes wrong conversion from quaternions to euler angles and vice versa. It was a convention issue. Raylib uses xyzw convention for quaternions but the conversions were for wxyz convention

krysperz2 avatar Mar 16 '23 09:03 krysperz2

@krysperz2 Thanks for the review! Could you provide some visual example that illustrates this functionality?

raysan5 avatar Mar 20 '23 17:03 raysan5

@raysan5 ~~Well if I am being honest I just copied the code from wikipedia. And I have never used these functions myself. I just saw it on the wish list and thought it was easy enough to fix so I did. But I will try to get an example working as soon as possible~~ Upon further investigation I have found that my fix was actually wrong. The convention used in raylib is that the scalar part of the quaternion is w, which is correct. The problem is that in the definition of quaternion and in the functions w is the last component. While in wikipedia or in books w is usually the first component. So I recommend changing the convention so that w is the first component in the definition and in calculations if that is okay with you.

krysperz2 avatar Mar 23 '23 09:03 krysperz2

@krysperz2 Sorry, it's not possible to change the convention for raylib. That's the reason I asked for a working example. I'm not merging this PR.

raysan5 avatar Mar 23 '23 10:03 raysan5