Lecture 1: General Simulation Concepts

21 Aug 2024


§ Simulation

Generally, we model forces and compute how they affect the acceleration of an object.

It is important to decouple the notion of simulation and rendering; ideally these two steps run in parallel. We don't want our framerate to affect how fast the physics engine is running, like in old games.

If the simulation is faster than display rate, then we can simulate at a fixed rate -- at the end of each simulation step set a timer to wait until the start of the next time quantum for the next simulation step.

If the renderer ends up being slower than the simulation, then we can decouple the two loops and run simulation and rendering in parallel. In the renderer, we can read the current state of the simulation.

§ State

In simulations, we usually store the state of the system, and generate a next state based on the information from the previous state.

For now, we can let the state S={x,v}\mathbf{S} = \{\mathbf{x}, \mathbf{v}\}

§ Explicit Euler

Explicit Euler Integration

v(n+1)=v(n)+ahx(n+1)=x(n)+v(n)h\begin{align*} \mathbf{v}^{(n + 1)} &= \mathbf{v}^{(n)} + \mathbf{a}h\\ \mathbf{x}^{(n + 1)} &= \mathbf{x}^{(n)} + \mathbf{v}^{(n)}h\\ \end{align*}

Update velocity and position by integrating their derivatives over time step hh.

§ Forces

Some examples of forces, other than gravity, that might be applied to an object

§ Air Resistance

Air Resistance

We can compute the force due to drag via

Fair=dvv\mathbf{F}_{\mathrm{air}} = -d \mathbf{v}\|\mathbf{v}\|

where dd is the coefficient of drag.

The coefficient of drag depends on things like the object's shape and size, and the density of the fluid its falling in.

Note that air resistance Fairv2\mathbf{F}_{\mathrm{air}} \propto \|\mathbf{v}\|^2, this is more difficult to simulate as we would require higher-order integration techniques (later in the course).

In animation, it is good enough to say that Fairv\mathbf{F}_{\mathrm{air}} \propto \|\mathbf{v}\| instead and let

Fair=dv\mathbf{F}_{\mathrm{air}} = -d \mathbf{v}