Nature of Code: String of Beads

I had fun playing around with the Box2D library a few weeks ago, and also enjoyed working with pendulum motion for this sketch. A string of pearls seemed to combine these ideas nicely – so, for the Nature of Code midterm assignment, I set out to recreate the motion and behaviors of a string of pearls.

The “big idea” is a string of pearls suspended from above, swinging from side to side until it collides with an object and snaps in half, allowing the pearls to fall to the ground. Once the pearls hit the ground, they will bounce and roll around on the ground until they eventually come to rest.

The string of beads is comprised of bead objects attached via joints. My first task was to create the appropriate joints to attach the bead objects to one another. I researched several joint possibilities in the Box2D library, and went with the Revolute Joint, which forces each set of 2 beads to share a common anchor point around which the two bodies can rotate.

The working Processing sketch and code can be found here.

My next step will be to make the beads collide with the boundary, snap the joints and make the beads fall to the ground.