For my Computer Animation and Simulation course, I implemented and compared several ways to fill in the frames between keyframes of motion-capture data.
Code: github.com/JackyLiu47/MotionInterpolate
The setup
Inputs are a skeleton file (.asf, describing bones, directions, lengths and degrees of freedom) and a motion file (.amc, the per-frame joint rotations). The program keeps every N-th frame as a keyframe, throws away the rest, and reconstructs them. Comparing the result with the original shows how good each method is.
Four interpolation schemes
- Linear interpolation of Euler angles (provided in the starter code).
- Bezier interpolation of Euler angles.
- SLERP interpolation of quaternions.
- Bezier interpolation of quaternions using SLERP-based control points.
The last three were mine to implement, and then compare on both speed and accuracy.
Running it
The project is C++ and builds on Windows, macOS and Linux. On macOS/Linux:
# view motions in a window
./mocaplayer
# interpolate: skeleton, motion, l|b, e|q, keyframe interval N, output
./interpolate 131_dance.asf 131_04-dance.amc b q 20 dance_bq.amc
That example runs Bezier interpolation on quaternions (SLERP) with a keyframe every 20 frames and writes dance_bq.amc.
Notes
The lesson that stuck: Euler angles are easy to reason about and treacherous to interpolate. Gimbal lock and angle wrap-around can produce visible jitter, while quaternions interpolate along the shortest rotation and look smoother, at the price of some extra math. Bezier curves then add smoothness across keyframes on top of either representation.
