Inverse & Forward Kinematics
Introduction
Inverse kinematics (IK) is the basis for quite a bit of character animation. IK is solving the angles at each joint to move multiple appendages to get the end effector to the chosen location. Simple eh? Unfortunately, it can get difficult and getting a good solution can get even more difficult.

This project's goal was to implement an IK solver and work with some forward kinematics interpolation.

Inverse Kinematics
There are multiple methods for solving the inverse kinematics problem. The simplest and the fastest is probably Cyclic Coordinate Descent.

CCD Algorithm
Originally described by Wang and Chen, the CCD algorithm is extremely simple. Start at the end (the furthest link from the root), adjust it towards the end goal. Move to the next link, repeat. Repeat until all links are done. Then begin again for the entire chain. With a few iterations, the chain will have reached the goal. Limiting how much an angle can change during any given iteration gives a smoother more nature solution. (Damping)

Implementation
The project application can be seen in the image to the right. It permits clicking the window, which moves the target for the arm, then the arm will move to the target using the solution given by the CCD algorithm. The angles at the joints are recorded and displayed in a graph at the bottom. (See Forward Kinematics for more about this.)

The project implemented classes for the IK chain, and IK link making it a general CCD solution. The projection application however is setup to use and solve a 3 link arm.

The project application showing a 3 link arm moved to a target (the yellow cross hair). At the bottom of the screen is a graph tracking the angles at each joint over time. The graph also illustrates interpolating the angles.
Forward Kinematics
Inverse kinematics works well for solving the angle problems, especially when setting up animations. Depending upon the system and application needs, it may not be feasible to run the IK in real-time. An alternative is to now use the key frames from the IK to drive a forward kinematics solution. This project includes a simple foward kinematics engine. It interpolates the Euler angles at the joints. (A real world system would use quaternions for their forward kinematics, and would not be restricted to solutions in the plane like this project.)

Interpolation
As described above, the project window has a graph which shows each joint angle in a different color, with time varying from left to right. The angles can be interpolated using a simple linear algorithm or a cubic algorithm. The following table shows the difference in the angles as interpolated over time with each algorithm. Actual keyframes are at the dashed lines.

Linear
Cubic

Notice when a joint changes direction how the linear interpolation provides for a harsh transition. What may not appear as too much of an issue in a graph becomes rather jerky motion when animating.

Spline based interpolation (Catmull-Rom, Hermite) could be added for even smoother animation.

glenn@raudins.com