I’ve started using the sweet timeline feature in Cinder to animate some text. However, I’ve hit a small snag. I’ve not really figured out if it’s possible to rotate anything using a quarternion more than 180 degrees with just a line of code or two, like so:
Instead this will rotate (as far as I know) the object to an angle more along the lines of 800 % 360. I have a vague idea of why, but I honestly am just keen to know if someone knows a way around it that doesn’t look like this:
you’re making the same mistake again. Like matrices, quaternions can not be interpolated using the formula a + t * ( b - a ) (where a and b are quaternions and t is a float).
So if we rotate around x, y, z there are 6 different orders of permutation and each will effectively achieve a different rotational outcome. I’m trying to figure out a smart way to use Timeline and Anim to allow the the flexibility using either of the 6 permutations. One ugly way would be to maintain a x,y,z rotation value for each of the 6 permutations and subsequently only change the numbers (from 0 to something else) on the rotations intended. In essence, all 6 permutations would be applied but only the ones you alter will provide you with something other than the identity matrix.
Hopefully what I’m trying to say is clear.
In any case, my idea feels super clunky but I’ve not come up with a better simpler one thus far. Any ideas are welcome.
it’s true that rotations aren’t commutative and the order is important. For that purpose, quaternions were invented. One way to look at quaternions, is that they encode a rotation around an arbitrary axis. What you could do, is animate both the axis and angle over time. Just make sure to normalize the axis before using it and to use radians for the angle.
You can then call: const quat rotation = glm::angleAxis( radians, axis );
And if you need a matrix from that (not always necessary), use glm::toMat4( rotation ).
-Paul
P.S.: one way to come up with an axis is to move two points a and b in space, then do axis = glm::normalize( b - a ).