Algorithm Search⌘K

Problemintro

Keyframe interpolation

Also called in-betweening, tweening.

Given the values of animation parameters at key times, compute a value for every frame in between, so that the motion passes through the keys and is smooth.

Keyframe interpolation is the problem at the center of key frame animation. An animator sets the values of the parameters of a scene, such as a joint angle, a position or an orientation, at a few key times. The computer must then fill in the values at every frame between the keys. The result must pass through the keys, it must be smooth enough to look natural, and it must not add motion that the animator did not ask for. In traditional animation, assistants drew these frames by hand, and the word in-betweening comes from that work.

In plain words

An animator tells the computer where things are at a few moments, for example where a ball is at the start, at the top of its bounce and at the end. The computer must decide where the ball is at all the moments in between. The simplest answer joins the keys with straight lines, but then the ball changes speed with a jerk at each key. Smoother answers use curves that bend through the keys. Turns of a body need their own methods, because angles wrap around and the order of turns matters. A good method also lets the animator say how fast the motion goes, apart from where it goes.

Definition

The input is a sequence of keys (t0,v0),(t1,v1),…,(tn−1,vn−1)(t_0, v_0), (t_1, v_1), \dots, (t_{n-1}, v_{n-1}) with t0<t1<⋯<tn−1t_0 < t_1 < \dots < t_{n-1}. Each value viv_i is a point of a space MM: the real line for one channel, R3\mathbb{R}^3 for a position, or the rotation group SO(3), with unit quaternions as coordinates, for an orientation. Some systems also take a tangent or a shape parameter at each key.

The output is a function v:[t0,tn−1]→Mv : [t_0, t_{n-1}] \to M with v(ti)=viv(t_i) = v_i for each key, evaluated at the frame times t0+k/ft_0 + k/f for a frame rate ff. The usual quality goals are:

  • Continuity. vv is C0C^0, C1C^1 or C2C^2 in tt. C1C^1 means no jump in the velocity, C2C^2 no jump in the acceleration.
  • Local control. A change of one key changes vv only near that key.
  • No overshoot. Between two equal keys, the value stays at the key value, if the animator asks for this.
  • Independence of coordinates. For positions and rotations, the result does not depend on the choice of the world frame.

The cost model is the real RAM. The cost has two parts: a build step once per set of keys, and an evaluation per frame and per channel.

Variants

  • Interpolating or approximating. An interpolating curve passes through every key. An approximating curve, such as a B-spline, only follows the keys as control points, and it is smoother for the same degree.
  • Step keys. The value holds until the next key. Animators use this to block out the poses of a shot before they ask for in-betweens.
  • Keys with tangents. The animator sets a tangent or a handle at each key, as in the Hermite spline and in the curve editors of animation software.
  • Rotations. The values lie on SO(3), or on the unit sphere of quaternions, and the methods use the group structure instead of coordinates.
  • Path and timing apart. The keys fix a path in space, and a separate curve fixes the distance along the path as a function of time. This needs an arc length table or an arc length parametrization, and an ease curve.
  • Shapes and images. Each key is a whole shape or image, and the problem becomes morphing, as in Beier-Neely morphing and as-rigid-as-possible shape interpolation.

Examples

Take one channel with the keys (0,0)(0, 0), (1,1)(1, 1), (2,1)(2, 1) and (3,0)(3, 0), and evaluate at t=1.5t = 1.5.

  • Linear interpolation gives 11, the value of the two keys around t=1.5t = 1.5.
  • The Catmull-Rom spline sets the tangent at key 1 to (v2−v0)/2=0.5(v_2 - v_0)/2 = 0.5 and at key 2 to (v3−v1)/2=−0.5(v_3 - v_1)/2 = -0.5. The cubic Hermite basis at s=0.5s = 0.5 is h00=0.5h_{00} = 0.5, h10=0.125h_{10} = 0.125, h01=0.5h_{01} = 0.5 and h11=−0.125h_{11} = -0.125, so the value is 0.5+0.0625+0.5+0.0625=1.1250.5 + 0.0625 + 0.5 + 0.0625 = 1.125.

The smooth curve rises above both keys, so the object floats up between two equal keys. This overshoot is the reason for the tension parameter of the Kochanek-Bartels spline: with tension 1 the tangents are 0 and the value at t=1.5t = 1.5 is 1.

Interpolating Euler angles per channel fails on rotations. Take a yaw angle with the keys 170 degrees and −170-170 degrees, which differ by 20 degrees. The midpoint per channel is 0 degrees, so the body turns 170 degrees back and then 170 degrees forward, through 340 degrees in all. Slerp of the two quaternions gives 180 degrees, halfway along the short turn of 20 degrees. With three angles the per-channel curve also depends on the order of the axes, and near gimbal lock a small change of the keys swings the angles wildly.

Known algorithms

For one channel or for positions:

  • Linear interpolation. C0C^0, local, no overshoot. The velocity jumps at each key.
  • Cubic Hermite interpolation with given tangents (Hermite spline, cubic Hermite spline). C1C^1 and local.
  • Catmull-Rom spline. A Hermite spline whose tangents come from the neighbour keys. C1C^1, local, and it can overshoot.
  • Kochanek-Bartels spline. Catmull-Rom with tension, continuity and bias per key (Kochanek and Bartels 1984).
  • Natural cubic spline. C2C^2 and interpolating, but each value depends on all the keys.
  • B-spline. C2C^2 and local for cubics, but it does not pass through the keys.

For orientations:

For timing:

  • Ease-in and ease-out curves and the time scaling of robotics change the speed along a fixed path.
  • Arc length tables give the curve parameter for a wanted distance along the path.
  • Steketee and Badler (1985) proposed a second spline for the timing of the keys, apart from the spline of their values.

Bounds

  • Evaluation. For a local cubic scheme, one value costs O(1)O(1) per channel after the segment is known. Finding the segment of a time costs O(log⁡n)O(\log n) by binary search, or O(1)O(1) amortized when the frames come in time order.
  • Build. Catmull-Rom and Kochanek-Bartels tangents cost O(n)O(n). The natural cubic spline needs one tridiagonal solve, also O(n)O(n).
  • Smoothness against locality. A C2C^2 cubic spline that interpolates the keys is fixed by the keys and two end conditions, so a change of one key moves every segment. For uniform keys the effect decays by about the factor 2−3≈0.2682 - \sqrt3 \approx 0.268 per key. Local cubic interpolants, such as Catmull-Rom, are only C1C^1.
  • Rotations. A single slerp segment is the shortest path between two orientations. A smooth curve through three or more keys that are not on one great circle must leave these arcs.

Reductions

  • Positions and other vector values reduce to one scalar problem per coordinate, because the linear schemes act on each coordinate apart and commute with affine maps.
  • Orientations do not reduce in this way. Interpolating quaternion components and then normalizing gives a curve on the sphere, but its speed and its shape depend on the scheme. The methods of the rotation list work on the sphere directly.
  • Timing control reduces to the composition v(s(t))v(s(t)) of a path vv with a monotone reparametrization ss, so the shape of the path and its timing are separate problems.

Applications

  • The joint angles and the root motion of a character in skeletal animation, and the inputs of motion blending.
  • Camera paths and camera orientations.
  • Light, color and material parameters that change over a shot.
  • Shape keys and morph targets, where each key is a mesh.

Burtnyk and Wein (1976) used skeletons to control the in-betweens of key drawings, in an early interactive system for computer-aided key frame animation. The principles of traditional animation, such as slow in and slow out and arcs, describe what a good in-between looks like.

References

  1. N. Burtnyk and M. Wein, Interactive skeleton techniques for enhancing motion dynamics in key frame animation, Communications of the ACM 19(10), 564-569, 1976, the whole paper (key frames as drawings on skeletons, and the interpolation of the skeletons)
  2. Doris H. U. Kochanek and Richard H. Bartels, Interpolating splines with local tension, continuity, and bias control, Computer Graphics (Proceedings of SIGGRAPH 1984) 18(3), 33-41, 1984, the whole paper (cubic interpolating splines for key frame animation, with three shape parameters per key)
  3. Ken Shoemake, Animating rotation with quaternion curves, Computer Graphics (Proceedings of SIGGRAPH 1985) 19(3), 245-254, 1985, the whole paper (the interpolation of orientation keys with quaternions, and the failure of Euler angle interpolation)
  4. Scott N. Steketee and Norman I. Badler, Parametric keyframe interpolation incorporating kinetic adjustment and phrasing control, Computer Graphics (Proceedings of SIGGRAPH 1985) 19(3), 255-262, 1985, the whole paper (separate splines for the values of the keys and for their timing)
  5. Rick Parent, Computer Animation, Algorithms and Techniques, 3rd edition, Morgan Kaufmann, 2012, Chapter 3 (interpolating values: curves, speed control and orientations) and Chapter 4, Section 4.1 (key-frame systems)

Where this leads

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH0 no proof
  • add a proof in proofs/ (06.5)
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW2 basic
  • a known algorithm
  • a contract.yaml