Assignment 4 - Inverse Kinematics

I implemented the Cyclic Coordinate Descent (CCD) method for inverse kinematics. The basic idea behind CCD is to iteratively change 1 degree of freedom at a time, starting at the bone closest to the end effector.

Video

Download video

Implementation

Joints

I used an euler angle representation for the joints, attempting to change one degree of freedom (X, Y, Z rotations) at a time. Unfortunately, I was unable to get full 3D working, though the models and algorithm have been built with 3D in mind. The demo is mostly in the 2D XY plane, and a small bit in the Z plane.

Rendering

I created a 3d model to have a nicer visual output (and for easier debugging!). The short end is the parent and the long end points towards the child, if it exists. In addition, you can use the arrow keys and WASD to move around the scene.

Out of Reach

The system gracefully handles situations that are out of reach, opting to stretch the joints as far as possible for an optimal solution. See the screenshots below for an example, or watch the video.

Constraints

You can specify (in the code, as a constant) whether to fix some of the joints to be completely stationary (as seen in the video). However, this is only a binary flag - you can either allow full 360-degree movement or none at all.

Sample Screenshots

4 Joints

8 Joints

Source

Download binary and source (requires Visual Studio 2010 with the XNA Framework). You will need the XNA 4.0 installer to run both the binary and source