Simulation Overview
The behavior of a trebuchet cannot be described with a single set of equations. During different parts of its launch, a trebuchet is subject to different constraints. The obvious change in constraints during the launch happens when the projectile is released from the sling and is no longer attached to the trebuchet. There is another, less obvious, change that also happens during the launch. At the beginning of the launch, the projectile moves along the ground. It has no vertical component to its movement. At some point, the constraints change and the projectile leaves the ground.
In this simulation, the trebuchet launch is divided into three stages, each with its own set of equations. There is a specific condition that is monitored at each stage. When that condition is met the simulation moves onto the next stage.
In stage 1 of the trebuchet simulation, the projectile is in contact with the ground and can only move in a direction parallel with the ground. During stage 1 the program keeps track of the force that the ground applies to the projectile to keep it moving along a horizontal path. At the beginning of the launch gravity wants to pull the projectile into the ground and the ground must push up on the projectile to keep it moving horizontally. After a certain point however, the sling pulls up on the projectile with a larger force than gravity pulls it down and the projectile transitions from pushing into the ground to pulling away from the ground. At this point, the ground would have to pull down on the projectile to keep it moving horizontally. When this transition from pushing to pulling occurs, the simulation is triggered to transition from stage 1 to stage 2.
In stage 2, the projectile at the end of the sling is free to move, unconstrained by the ground. In stage 2 the program keeps track of the angle of the velocity vector of the projectile relative to the ground, and when the angle of the velocity vector gets within a certain tolerance of the user specified release angle, the simulation is triggered to transition from stage 2 to stage 3. This transition is the release point.
In stage 3, the projectile is completely independent of the trebuchet. In stage 3 the program keeps track of the height of the projectile relative to ground. When the height becomes negative, that is the projectile goes below the ground, the simulation ends.