In this section, the goal is to create toy system that simulates a spring. A brief review (with more extensive references) appears in the appendix.
If that section is too ad-hoc, there are many more “textbook” treatments of both of those subjects avalible. If you would like to use computers as a learning tool, Nature of Code offers one such outlet. This interactive presentation also offers a more complete treatment of relevent ideas.
With that non-overview, it’s time to build our first demo. The goal here is twofold:
One consequence of (2) is that there are some aspects of the first few examples which could be simplified, but are the way they are in order to make the introduction of the full system more gradual.
The system below implements Hooke’s Law for springs. Do you notice anything weird happening when you change the initial mass position?
We will be expanding on this code in the coming sections. If you want to follow along, some things to think about: