An example from the final chapter of my book, Making Things See: 3D Vision with Kinect, Processing, Arduino, and Makerbot shop.oreilly.com/product/0636920020684.do
A Processing sketch tracks the position of my head and uses inverse kinematics to calculate joint angles in order to control the robot arm so that it follows my head.
The forward kinematic version, which mimics the movements of my arm is available here: vimeo.com/31698679
You can see the debug output from this sketch that illustrates the positioning of the arm here: flickr.com/photos/unavoidablegrain/6323156312/in/photostream
A diagram explaining the math behind the 2D inverse kinematics is here: flickr.com/photos/unavoidablegrain/6323380287