A Brief note on Granny's quat interpolation
What Casey does in Granny is the right way to do animation playback. Let me quickly describe it. The only
difficult part is rotation interpolation, so I'll just talk about that.
You have some source data, which is a series of key-frames at high resolution. Generally this is Maya or
something. We're going to fit a cubic spline to these keys. The way we make a spline of rotations is
just by splining the four components of a quat. More on this later, for now take it that we have a spline
of quat keyframes. Start by putting a spline key on every source key. Then solve to reduce the number of
keys to some error metric. You wind up with a spline with very few keys, that satisfies some tweakable
error parameter (there are a lot of important details in measuring the "error" that I won't discuss here).
So, the big problem is just - how do you make a spline of rotation (quat) keys. Well, the clever thing
Casey does is just do a spline one each component. Now, technically that means we are linearly interpolating
quats, which makes them no longer be valid normalized quats. What that really means is we are taking the
quats (which are a double-cover of the rotation group, quats have topology S3) and we are just boosting them
to R4. We then interpolate them in R4 and finally we bring them back to S3 to use as rotations. Now, there
are a lot of maps we could use for S3->R4->S3 (see the paper by Johnstone and Williams), but a pretty good
one is just to take the quat components as-is to get from S3->R4 , and then to get back to S3, you just
normalize the 4-vector. Note that in practical use, you don't actually normalize, since you are probably
converting to a matrix, you just use a routine that can correct convert a non-normalized quat to a matrix.
The map R4->S3 does have a pole at {0,0,0,0} in R4, but that pole can be easily avoided in the spline, since
it would only occur if two keys were exactly opposite. (every map S3->R4->S3 has a pole at at least one point,
so you must choose it appropriately).
Now, you may think that just splining the components in R4 would lead to poor quality interpolation, since
really something like slerp is more natural for quats. That's not the case, because the key here is that
you're fitting a spline, and you're measuring the error in terms of actual rotations, so the choice of spline
components minimizes the error is real rotation terms. Now you might suggestion that using a slerp-based
spline could lead to using fewer spline coefficients for the same error value. Yes, in some cases, that is
true (for example, if your animation is just a rotation for A to B degrees at a fixed speed), but for real
data it usally isn't true, and furthermore, since we have a cubic spline, we are implicitly getting a cubic
fit of the slerp function (!).