Let's Get Lost Meandering Explorations of Shape and Space

Dream Herding

If it were possible to create a reliable simulation of reality, then odds are that our reality is itself a simulation.

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.

Spring in a Teacup

With that non-overview, it’s time to build our first demo. The goal here is twofold:

  1. To build an interactive spring simulation aimed at building intuition
  2. To setup and expose a skeleton of code which will progressively gain flesh

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?

X position

We will be expanding on this code in the coming sections. If you want to follow along, some things to think about:

  • Notice how there are constants at the top of the file. Try changing them and rerunning the simulation. Does it behave as you would expect? This is the “physics” of our simulation.
  • The middle of the file is the implementation of numerical integration. Think about the connection between the code and the mathematical ideas. This is the “math” of simulation.
  • At the bottom of the file, there is the “render loop”, where the system is evolved in time, and the representation of the system updates a picture. Try changing values here to see what happens.

Tangents: The approach taken in the design of this site takes much inspiration from Bret Victor (this is a good place to start) and William Thurston. And to add a tangent to a tangent, here is an opinion of Doron Zeilberger.

In short, the internet provides a new tool for thought and communication - exploring applications of this tool that help more people to see a little further and more clearly than they would have otherwise feels like a socially productive use of time.