Physics with Danno

Previous Chapter: Collisions
Next Chapter: Calculus primer

Lesson 2: Simulation graphs

I'd like to start analyzing some simple simulations. I'm a visual person, so I say we start graphing things. But what should we graph?

loop for every instant of time {
    loop for every object {
        1. force = ...
        2. dvel = force / mass * dt
        3. velocity += dvel
        4. dpos = velocity * dt
        5. position += dpos
    }
    time += dt
}

Well there's only a handful of piece of information in this loop.

Each object has a mass, but those don't change over the course of the simulation. Clearly, because the simulation loop from a couple slides ago doesn't have a line saying "mass += something".

The quantities that do change are time, the force being felt by each object, each object's position, and each object's velocity. So to start, I suggest that we just graph each of the major variables by every other major variable. There's only 4:

So after removing duplicates, that's just 6 graphs:

force / time

timeforce
timeforce
timeforce

First up is force/time. Notice how, in all 3, the graphs for the left and right ball have perfect vertical symmetry. Hopefully that should make sense: at every timestep forces are always equal and opposite. At any given timestamp, whatever force the right object feels, the left feels but negative.

Another interesting difference between the graphs is that some are shifted to the left. The reason is because we represent mass with the radius of the balls in these simulations. So in the simulations where there is a larger ball, it has a larger radius, and so they end up colliding sooner. So this is kind of a silly difference.

A more interesting difference is that in some of the simulations the "base", the amount of the x-axis where the graph lifts off, is wider. We might talk about that later on.

position / time

timeposition
timeposition
timeposition

Not much to say here, except notice the weird kind of diagonal almost-symmetry these graphs have.

velocity / time

timevelocity
timevelocity
timevelocity

We're going to be talking about this one extensively very soon, so I'll hold off on this one.

force / position

positionforce
positionforce
positionforce

Again, we're going to be talking about this one very soon, so I'll hold off.

The only thing I wanted to say is to notice that in that last one, the graph doubles back on itself! The x-axis cooresponds to the balls' positions, and the balls can turn around and move backwards.

force / velocity

velocityforce
velocityforce
velocityforce

Again, not much to say, except cool symmetry.

velocity / position

positionvelocity
positionvelocity
positionvelocity

Not much to say, except cool almost-symmetry.

Changelog:

Previous Chapter: Collisions
Next Chapter: Calculus primer

© by Daniel Taylor