I have four keyframes in an animation, f0, f1, f2, f3, and I am trying to interpolate a rotation of a frame f located sometime between f1 and f2 at t = (f-f1)/(f2-f1).
My question is, can I do a quadratic interpolation between the keyframes to find the rotation? I want to use all four keyframes. I also would like it to be C1 continuous across keyframes.
I have looked into SQUAD and Catmull-Rom Splines, but I'm still a little hesitant to implement them because I'm not sure what exactly the formulas should look like. SQUAD tells how to interpolate between a series of rotations, I am unsure about how to apply it to just four. Thanks in advance!
Unfortunately, quaternions don't live in a linear space, so interpolation between them is a bit tricky, as you found out already.
I assume you want to use a weighted average, in the same way you would compute a curve in 3D space.
First of all, an exact spherical interpolation (SLERP) of more than two quaternions is not defined. This is because their combinations is described using multiplication, and their multiplication is non-commutative (apart from other reasons). So you will have to make use of an approximate solution, as every other animation software :-)
SQUAD (aka Shoemake's Quaternion curves) are one possibility, or even fancier (and more accurate) optimization-based generalized quaternion interpolation. However, in practice I always made use of NLERP (normalized linear interpolation, described for example here), which gives good results if the interpolated quaternions are reasonably close (difference of about 60 to 90 degrees is still fine) while being very simple and fast. A nice simple article with 3D vector examples that shows the difference between these is here.
Personally, I always go back to Geometric Tools' Quaternion Algebra and Calculus notes, which have an extremely concise description of both theoretical and practical aspects of quaternions in CG.
And don't forget about antipodality, by far the most common problem when implementing quaternion interpolation :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With