// Function to update location
 public void update() {
   // As long as we aren't dragging the pendulum, let it swing!
   if (!dragging) {
     float G = 0.4f; // Arbitrary universal gravitational constant
     theta_acc = (-1 * G / r) * sin(theta); // Calculate acceleration (see:
     // http://www.myphysicslab.com/pendulum1.html)
     theta_vel += theta_acc; // Increment velocity
     theta_vel *= damping; // Arbitrary damping
     theta += theta_vel; // Increment theta
   }
   loc.setXY(r * sin(theta), r * cos(theta)); // Polar to cartesian conversion
   loc.add(origin); // Make sure the location is relative to the pendulum's origin
 }