Quaternion Interpolation

In my proposal above, I discussed what I thought was squad, but actually turned out to be a different interpolation approach. I also said in my edit that “I don’t think squad itself is actually useful”, which was overly curt and didn’t qualify what I really meant well enough.

Since then, I’ve done a further dive into quaternion rotation interpolation techniques. I certainly don’t fully understand everything I’ve encountered (in some cases the math is currently a bit beyond me), but I nevertheless want to share what I’ve found so far.

First off, although this is probably obvious, slerp is pretty much the “right” way to do linear interpolation for quaternion rotations, in the sense that it’s the only approach–by definition–that gives constant-speed rotation around a single axis. So that’s easy enough.

When you get into smooth interpolation, however, things get a lot more complex, and to some extent subjective. This shouldn’t be too surprising, since that’s the case in euclidean space as well: straight lines are obvious, but smooth interpolation has all kinds of approaches.

Squad

Squad, despite its name, is actually a cubic interpolation technique. The “quad” stands for “quadrangle”, not “quadratic”. It was introduced by Ken Shoemake in a 1987 paper entitled “Quaternion calculus and fast animation” that apparently is no longer available anywhere.

It takes an approach introduced by Wolfgang Boehm in “On cubics: A survey” for constructing cubic curves with only 3 lerps, and extends it straightforwardly to spherical space with slerps:

slerp(slerp(start, end, t), slerp(handle_1, handle_2, t), 2t(1 - t))

Although the Shoemake squad paper is no longer available, given its title I suspect the main motivation for proposing squad over other approaches was performance. It takes only 3 slerps compared to e.g. the 6 slerps of spherical bezier.

However, it doesn’t produce the same curve as a spherical cubic bezier curve. As far as I was able to determine from the papers I read (but take this with a grain a salt), the full cubic bezier produces visually smoother, more pleasing curves than squad. So it may be the case that squad is sort of the “poor man’s” spherical bezier, and its only benefit is execution speed.

Shoemake’s original spline construction equations (i.e. “auto” curves in Blender) for squad apparently have continuity issues: although the curve segments themselves are c2 (in fact, c-infinity), the composite splines are only c1. c2 is certainly not critical for auto-curves, but it is a nice-to-have and can be visually noticeable.

Spherical Cubic Bezier

This is the approach I mistakenly called squad, and is what Shoemake outlined in his earlier 1985 paper “Animating Rotation with Quaternion Curves”.

As mentioned above, it may produce nicer curves than squad, but it’s roughly twice as expensive to evaluate.

Just like squad, Shoemake’s spline equations for spherical cubic bezier are only c1-continuous.

RQBez

This is the approach that Blender currently uses. You do the interpolation with standard euclidean bezier curves, and re-normalize the resulting quaternions afterwards.

The paper “Survey of Higher Order Rigid Body Motion Interpolation Methods for Keyframe Animation and Continuous-Time Trajectory Estimation” by Haarbach et al. call this approach “Renormalized quaternion Bezier curve”, or “RQBez”.

Looking at the examples in that paper, IMO this approach actually produces nicer results than squad. In particular, the velocity acceleration/deceleration seems to be more uniformly smooth, whereas squad is kind of bouncy with sharp transitions at the keys.

Another potential benefit of RQBez is c2 continuity. The equations for c2 bezier splines in euclidean space are well known (and already implemented in Blender), and I think it’s the case that they remain c2 after normalization.

(My intuition behind that is it seems like projecting a c2 curve onto a c-infinity manifold like the hypersphere ought to preserve that continuity. But I’m not totally sure–someone please feel free to double-check. In any case, if that’s true, then we get c2 continuity without having to do anything special.)

This approach is also very performant, and it’s obvious how to implement “auto clamped”, etc.

Other Approaches

There are a whole bunch of other approaches for interpolating quaternions smoothly. A quick run-down of some papers that propose other methods:

  • "A General Construction Scheme for Unit Quaternion Curves with Simple High Order Derivatives" by Kim et al. The method proposed here is a spline that is cubic, has c2 continuity, and doesn’t appear to be too much slower than squad. However, it doesn’t pass through its control points, which makes it unusable for animation interpolation.
  • "Quaternion Cubic Spline" by McEnnan. This paper is beyond me (at least without spending a lot more time with it), but it does appear to propose a spherical spline that is c2 and passes through all points. I have no idea how tweakable it is by animators, however.
  • "C2 spherical Bezier splines" by Popiel et al. I haven’t found a copy that’s not behind a paywall, but the abstract as well as the way it’s referenced in another paper suggests that it contains an approach for constructing c2-continuous splines from both squad and spherical cubic bezier curves. If someone wants to track this down, that would be awesome.
  • "Quaternions, Interpolation and Animation" by Dam et al. This paper proposes an optimization-based approach to interpolating quaternions. It’s interesting, but I suspect we probably don’t want to use an interative optimization approach for animation interpolation.
  • "Survey of Higher Order Rigid Body Motion Interpolation Methods for Keyframe Animation and Continuous-Time Trajectory Estimation" by Haarbach et al. They don’t propose any new methods in this paper, but as the name of the paper suggests they do provide a survey of rigid body interpolation approaches, the rotation component of which is all quaternion-based approaches.

Wrapping up

All-in-all, my impressions at this point are as follows:

  • The solution-space for smooth quaternion rotation interpolation is complex, and there are a lot of competing approaches. They all seem to have pros and cons, and there isn’t a clear universal “winner”.
  • Squad’s main selling point seems to be speed rather than quality. Importantly, it isn’t special compared to other approaches, and isn’t any kind of “natural” extension of slerp, despite the impression its name gives. If anything, the spherical cubic bezier approach is a more natural extension.
  • The seemingly brain-dead RQBez approach actually appears to have some advantages, including speed, probably (?) c2 continuous splines, a straightforward f-curves workflow, and an obvious way to implement “auto clamped”.

Having said that, this was certainly not a thorough deep-dive into the subject matter, and I easily could have misunderstood some of the papers. As I said at that start of this post, the math involved in some of these papers is a bit beyond me at the moment.

6 Likes