Particle System  Rigid Bodies


Particle system algorithm:This example shows a simple particle system where each particle is represented by a rigid body with a rotation and an angular velocity:
1. Remove rigid bodies with age > max. life timeThe life time of each rigid body is set to 0 when a rigid body is generated. In each simulation step the life time is increased by the time step size $\Delta t$. When a rigid body's life time is greater than a predefined maximum life time, the rigid body is removed from the simulation. Note that the life time can be used for rendering effects. In our case the transparency is increased depending on the life time to fade out the rigid bodies. 2. Generate new rigid bodies by emittersIn each simulation step new rigid bodies are generated at the position of the emitter. Typically they are initialized with some predefined values and sometimes some random values are added to obtain more natural results. In our simulation the rigid bodies are generated with a velocity pointing upwards. Moreover, the velocity in x and ydirection is modified by some random values. The starting position of the body is at the emitter and it has a random rotation and angular velocity. 3. Compute forces for all rigid bodiesIn each step forces are determined for the rigid bodies, e.g. gravity, wind etc. In our simple example only gravity is applied. 4. Time integrationFinally, the rigid bodies are advected by numerical time integration. In our case we use a symplectic Euler method: $$\begin{align*} \mathbf v(t + \Delta t) &= \mathbf v(t) + \frac{\Delta t}{m} \mathbf f^{\text{ext}} \\ \mathbf x(t + \Delta t) &= \mathbf x(t) + \Delta t \mathbf v(t + \Delta t) \\ \alpha(t + \Delta t) &= \alpha(t) + \Delta t \omega, \end{align*}$$ where $\mathbf f^{\text{ext}}$ are the external forces, $\omega$ is the (in our example constant) angular velocity and $\alpha$ is the rotation angle. 