CPSC 533D Assignment 3
Rigid Body Dynamics
In this assignment you will be implementing the key
parts of a rigid body dynamics simulator.
It will simulate the motion of a single rectangular block
that is thrown into the air and then collides with the ground plane.
What you need to do (and a recommended order)
- Compute and integrate the linear acceleration to get a moving
(but not rotating) block which will simply cause to fall through
the ground plane.
- Compute and integrate the angular motion of the object.
The block should now spin (while still falling) due to the angular momentum
assigned in the initial state. The block will spin in a fairly
stable fashion with an initial spin around it's x-axis or z-axis,
but will be unstable when spun around it's y-axis.
- Implement collision detection.
Detect when a vertex first collides with the ground (z=0)
and pause the simulation then by setting Simulation = false;
- Implement collision response. The code for this is
already largely in place. You just need to compute j,
the magnitude of the impulse.
- Submit a tarfile with your working code. Add a README.txt file that
describes any issues you came across, any additional keybindings
that you may have added, etc.
Template code
http://www.cs.ubc.ca/~van/cpsc533D/a3/rbsim.tar.gz
Key bindings for the template code
space start/pause simulation
q quit
r reset block to initial state
> increase eps, the coeff or restitution
< decrease eps, the coeff of restitution
Functions that you need to implement
- block.cpp: BLOCK::sim()
- block.cpp: BLOCK::collisionCheck()
- block.cpp: BLOCK::collisionImpulse()
Things that are useful to know
- Look at lib_math.h for the provided math functions.
- Don't expect your simulation to properly handle resting contact.
This has not been discussed in class and so we will skip this.
- Use either L or omega as your state variable that drives changes
in angular orientation. You will need to compute dL/dt or
omega_dot to integrate these choices, respectively.
- VEC4 is a 4-vector, but it is also used liberally in the code
to represent 3-vectors.
- The code should compile equally well under Linux and Windows.
Let me (van@cs) know if you run into compilation problems.
It relies on OpenGL and glut.
- The drawing code makes use of the current transformation
matrix, TM, to draw the block. It is transposed before
being passed on to OpenGL because OpenGL
expects matrices in a column-major form.
- Use the functions I_inertial() and buildTM(),
found in main.cpp to compute the inertia tensor in the inertial frame,
and to build the object transformation matrix, respectively.
- See sim.pdf
for a derivation of how to compute the collision response magnitude, j.
Last modified: Thu Nov 10 00:16:07 Pacific Standard Time 2005