By Will Morland
The trebuchet is made up of 5 main parts.
The latter 4 components are built out of 2D springs attached to particles. The components are attached by shared particles- the particle at the bottom left of the arm, for example, is attached to each end of the pouch by springs.
The payload, however, is just a particle.
Each of the 5 components has different properties in order to make the trebuchet work. The springs in the arm, counterweight, and frame all have much higher stiffness than the pouch, to stop the components from bending. The counterweight has a higher mass than the arm and pouch, but a lower mass than the frame, to stop the trebuchet from flipping.
Here's what happens when I change the arm to be less stiff:
As you can see, the arm deforms, and the trebuchet does not launch the ball.
There's two parts that have special properties, both located in the pouch: the breakable spring, and the pouch itself, which collides with the payload.
As you can see in the diagram below, the pouch is connected to the arm by two ropes: one is held on permanently, while the other has a loop at the end, which comes off of the peg at the end of the arm when the ball is released.
Instead of creating a loop, I decided on a simpler approach: to break the spring that represents that loop at the right time.
When the spring is created, it stores its original length. As the animation plays, the springs stretch and contract. When this spring is stretched to 1.11 times its original length, it breaks, and isn't drawn anymore, and doesn't impose forces on its particles.
As a result, you can see the pouch flopping around, only attached by one spring.
The pouch and ball collide when the pouch's particles enter the ball's radius. When this happens, the particles impose a force on the ball, and vice versa, based on the depth of the collision and the direction the particle is hitting the ball from.
Since the collisions are only between circles, the collision detection algorithm is simple.
The force the ball recieves allows it to counteract gravity, and get launched.