# Motion interpolation (computer graphics)

Motion interpolation is a programming technique in data-driven character animation that creates transitions between example motions and extrapolates new motions.
Example motions are often created through keyframing or motion capture. However, keyframing is labor-intensive and lacks varieties of motion, and both processes result in motions that are time-consuming to alter. Motion interpolation provides a much faster alternative to creating new motions through the same means.

## Implementation

Formerly, a popular method of simulating a character's movement involved storing a variety of motions and choosing the most appropriate one during run-time. Unfortunately, storage limitations resulted in repetitive or imperfect results. Instead, with some additional computation, new, desired motions can be created by interpolating preexisting, similar motions. Using interpolation, motions can be generated in real time while preserving the realistic qualities of the example motions.

### Simulated figure

The simulated figure that is manipulated to show the motion is represented as a hierarchical connection of rigid links by joints. The root of the hierarchy has six degrees of freedom: three degrees for the figure's position and three degrees for the figure's rotation. This representation is sufficient, because knowing only the degrees for each joint and the root, the figure can be rendered at any time.

### Interpolation

Suppose that for a desired motion, "walk," there exist two example motions that convey different moods (e.g., happy and sad). A happy walking motion may be characterized by a simulated figure's posture being upright and its gait being energetic and fast-paced. A sad walking motion may be characterized by a slouched posture and a slow gait.
To interpolate these motions, they must be in canonical form. This means that their times must be made generic so that significant structural events occur simultaneously. To elaborate, the two example walking motions may vary in time, as the happy walk is described as fast-paced and the sad walk is described as slow. However, scaling their lengths of time to be equivalent is not sufficient for interpolation. This is because the slow walking motion is not simply an elongation of the happy walking motion. These motions must have their walk cycle key frames aligned, so that at a given generic time, both motions make a forward point contact.
For a neutral walking motion that is neither (or equally) happy or sad, the corresponding degrees of freedom for the existing motions are used for interpolation. As a result, a tuple of degrees of freedom is created for a simulated figure walking a neutral walking motion at a generic time. Alternatively, if the mood of the simulated figure were to change in real time from happy to sad, the interpolation would be more influenced by the happy walking motion at the start of the transition. Towards the end of the transition, the interpolation would be more influenced by the sad walking motion until the figure simply walks the sad walking motion.
A transition between two types of motions (e.g., a walking motion and a running motion) involves the interpolation of velocities. This ensures a smooth transition. A transition between two types of motions requires either be a generic time frame where both types of motions share structural similarities, or a series of motions with transitional periods that eventually reach the desired type of motion.

### Inverse kinematics

Inverse kinematics can be used with real-time motion interpolation to create interactions with a virtual environment. As aforementioned, there is a necessary process of annotating example motions with significant structural events. These annotations allow for the reparameterization of time to generic time. However, these annotations can also be used to specify periods where inverse kinematics should be used. For example, during a forward point contact in a walk cycle, kinematic constraints should be enabled so that the foot of the simulated figure is flush with the floor of the virtual environment.

### Searching for relevant motions

For large sets of example motions, the process of finding relevant results is not trivial. Therefore, methods have been developed to extract motions based on logical similarities and to combine these results into a continuous, branching space of motions that can be searched.