Simulates a mass-spring system.