I am attempting to code a simple spring mass system simulation in which a sphere pendulus hangs from a string (a spring) by the top and then another sphere (controlled by the user) can move and interact (collide) with this hanging sphere.

I have already coded the dynamics of the spring part of the simulation, but I do not know enough to add the rigid body dynamics. I would like either an explanation or a source to understand how to algorithmicaly do this simulation.


1 Answer 1


The rigid body simulation is very similar to the point mass case except for that we have to handle rotational motion (orientation and angular momentum).

In addition to common particle attributes such as mass, position, and linear velocity, we will need to store initial moment of inertia $\mathbf{\hat{I}}$, current angular momentum $\mathbf{L}^n$, and current orientation $\mathbf{R}^n$. If you are using a data driven particle system, this step is as easy as declaring a few new attributes.

Contract to the mass, the moment of inertia at current time step $\mathbf{I}^n$ depends on the current orientation $\mathbf{R}^n$: $\mathbf{I}^n=\mathbf{R}^n \mathbf{\hat{I}} (\mathbf{R}^n)^T$.

The kinetic of a rigid body is analogous to the linear motion: $$ \begin{align} \dot{\mathbf{R}} &= \omega^* \mathbf{R} \\ \frac{\mathbf{R}^{n+1} - \mathbf{R}^n}{\Delta t} &= (\omega^{n*}) \mathbf{R}^n \\ \omega^n &= (\mathbf{I}^n)^{-1} \mathbf{L}^n \end{align} $$ where $\omega$ is the angular velocity and $\omega^*$ is the "cross product" matrix.

For dynamics, we also have a similar version of Newton's "f=ma": $$ \frac{\mathbf{L}^{n+1} - \mathbf{L}^n}{\Delta t} = \tau^n $$ where $\tau$ is the torque.

Because there will be interactions between rigid spheres, you will also need to implement the collision detection for spheres.

Now we have known the kinematics and dynamics of rigids. The only thing left is how to solve (integrate) above equations. The naive forward Euler may not give stable result. A good introduction of this topic can be found at Witkin and Baraff SIGGRAPH course, and here is an another more recent SIGGRAPH course by Bargteil and Shinar.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.