The Physical Model
There are three kinds of entities in this world: balls, anchors, and springs. A ball is a particle that has a mass m, position (x, y), and velocity (vx, vy). The mass is constant, but the position and velocity vectors are updated during each animation frame based on the total forces acting on the ball. The balls are depicted as green circles. There is also a gravitational acceleration g = 9.8 m/s² that pulls the balls toward the bottom of the screen.
Updating Position and Velocity Vectors
After tallying the forces acting on all the balls,
Update goes back and updates the positions and velocities for each ball based on those forces. The kinetic behavior of the balls is governed by the familiar Newtonian physics equation F=ma. This says that the total force vector F on a mass m causes the mass to accelerate with a vector a.