Making use of the rotation {that a} quaternion represents is finished through multiplication. That is actually neat, as a result of it really works on vectors, like so:
v2 = q * v1
but in addition on different quaternions:
q2 = q * q1
…which implies that combining rotations is kind of straightforward. The draw back is that, in comparison with euler angles, it’s kind of harder to right away translate between your instinct of what a rotation is like and its quaternion illustration (though I discover that quaternion rotations appear far much less arcane if you consider angle-axis rotations, since there’s a very simple conversion between the 2).
To your case, since you understand the Euler illustration of the rotation you need, you would possibly need to simply convert that on to a quaternion and multiply it by the present rotation each body (observe that the order issues, quaternion multiplication is just not commutative).
I am undecided if glm has a built-in conversion between the 2 fashions, however the reply I linked earlier than has a number of examples of how one can implement one should you want it. So, upon getting the eulerToQuaternion
operate, you are able to do one thing like this:
Quaternion q = eulerToQuaternion(0.01, 0, 0);
void GameLoop::replace(){
pawn.rotation = q * pawn.rotation;
}
Additionally, as as to whether it is a good suggestion to make use of quaternions or not, it type of is determined by what precisely you’re doing, however I feel the overall consensus is that sure, they’re essentially the most handy method to work with rotations. The wikipedia web page on the topic says:
In comparison with rotation matrices, quaternions are extra compact, environment friendly, and numerically secure. In comparison with Euler angles, they’re less complicated to compose. Nevertheless, they don’t seem to be as intuitive and straightforward to know and, as a result of periodic nature of sine and cosine, rotation angles differing exactly by the pure interval shall be encoded into an identical quaternions and recovered angles in radians shall be restricted to [ 0 , 2 Ï€ ].
Which sums it up fairly properly, I feel.