How does a Trebuchet Work?

A trebuchet is a siege engine invented China in the 4th century BC, and it is used for throwing large rocks. It is comprised of a frame holding a long pivoting beam, with a counterweight on a hinge at one end and a sling with a large object, usually a rock, hooked to the other. It all sits on a track on the ground. When the weight is released, it drops, rotating the beam and causing the rock to slide down the track in the sling until it gets freed, and then the sling rotates very quickly up and over the beam and slips off the hook, hurling the rock for quite a distance.