The first applet was model in the same way. Use the center of gravity relative to the supporting point as a pendulum to model the system.  You can check out how it was done.