Reputation: 85
I have recently been experimenting with quaternion rotations, and I have made a class that stores the rotation as a quaternion. And I then want to take this quaternion and simply add rotation in the eulerY axis. This is what I came up with:
glm::vec3 tmp = glm::degrees(glm::eulerAngles(GetTransform()->rotation));
tmp.y += rotY;
GetTransform()->rotation = glm::quat(glm::radians(tmp));
And everything is working, however when the eulerY axis gets to 90 degrees, and I want to go above that, it does not let me. the X and Z axis keep changing from 0 to 180 or -180 and then back very quickly. And sometimes, when I then change rotY to a negative number (I try to lower the eulerY axis) then it does the exact oposite (the eulerY axis gets increased), suddenly ignoring the 90 degrees barrier. Any ideas what might be happening ?
I have tried different ways of how to do this, tried to add/remove the glm::radians or glm::degrees functions, but still nothing. I do not even know where this is even caused, it makes me so confused that I literally left my projects for a month out of frustration
Upvotes: 0
Views: 312