Rigid Body Dynamics


In this assignment, we had to either write a program to simulate constrained dynamics (Part A, a bead on a wire) or rigid body dynamics (Part B). I decided to extend my last assignment to incorporate impulse-based rigid body dynamics for collision response.

Implementation

As this program is an extension of homework 2, the implementation details about collision detection, etc. can be found there. I made a few modifications to more robustly determine the time of contact for colliding bodies. I implemented a simplified version of the bisection method that only bisects backwards until a point when intersecting bodies were not colliding (i.e., it never proceeds forward in time). Collision response is performed using conservation of linear and angular momentum. The coefficient of restituion is currently hard-coded as 0.8. There is currently no implementation of resting contact or friction. The simulation is run using Euler integration.

Viewer navigation was done using GLVU and the GUI was created with GLUI. Here are screenshots of the program and GUI.

Program options

There are several options you can set in the program. Most of them are self-explanatory. If the tessellation level is set to -1, the program chooses a random tessellation level for each sphere-like object. You can also choose to have each sphere's radius generated randomly or set a constant value. The obstacles checkbox determines whether or not obstacles will be present in the environment. Each obstacle has an "attraction" force similar to gravity that is based upon the supplied parameter, object mass, and distance from the obstacle. This can be used to make the objects fly around the scene and collide more often, etc. Many of the parameters will not take effect until the Reset button is pressed (the parameters that require a reset are greyed out when the Start button is pressed -- the rest can be changed during simulation).

Code...

...can be downloaded here!