Springs

Swarm · f(r) between bodies

f(r) = r − 1

Open in the app The dials and keys named below are the app's.

The setup

r − 1 is a spring, read as positive where the pair pulls together. At r = 1 it is zero, that is the rest length. Above 1 it pulls the pair together, below 1 it pushes them apart, and it grows without limit either way. Every pair of bodies is joined by one, so twelve unit masses are all sprung to all the others. They start on a disc of radius 1.5, turning as one at Swirl 0.5.

Springs between every pair

Because the law is linear, the sum over the other bodies splits into two pieces. The r part gives 12·(c − rᵢ), where c is the centroid: one spring from each body to the middle of the swarm, whose stiffness is the number of bodies. The −1 part gives a unit shove away from each of the others, which depends on their directions and not at all on how far off they are. So the cloud is a single stiff spring holding it in and eleven unit shoves per body holding it out. It settles at the size where the two balance.

Why it breathes

That structure leaves one dominant motion: the whole swarm swelling and shrinking together. The spring alone gives small swings a period of 2π/√12 ≈ 1.81 seconds. The swing here is wide, from a knot half a unit across to twice that, and the shoves stiffen the bounce. So the cloud breathes every 1.45 seconds at Speed 1, while the swirl turns it slowly.

The swarm is seeded about its own centroid, so the twelve starting velocities cancel and it carries no net momentum. Every force here comes in an equal and opposite pair, so nothing in a pairwise law can give the whole a push. The centroid stays where Cloud centre x and Cloud centre y put it, however long the cloud breathes.

Try

  • Set Swirl to 0: the bodies start at rest, so there is no spin, and the swarm breathes without turning.
  • Change the formula to 3(r − 1): three times the stiffness shortens the breath by √3, to about 0.86 seconds.
  • Change it to r − 2: the rest length doubles, so the knot settles about twice as wide and breathes more slowly.
  • Set Bodies to 30: the spring to the centroid is as stiff as the count, so the swarm breathes faster, about every 0.95 seconds.

Read more

Swarm · f(r) between bodies