3501 #7: Rigid Body Motion
Assignment 7: Rigid Body Motion
Due date: Wednesday, Dec 1
This assignment will let you build a simple rigid body simulator
(without collisions). You will implement torques and orientation
changes in a simple setting.
This is a bonus assignment. If you do this assignment, your mark on
the assignment will replace one of your the other assignments (either one
that you missed, or the assignment on which you got the lowest mark.)
Part 1: setup
- Download the submarine demo from the 3501 site.
- Run it to make sure it works before starting to modify it.
- Look carefully at the Boat.cs file, which has the setup
and simulation code for the submarine. Notice that there is an orientation
quaternion, but no change in orientation, and forces, but no torques.
Part 2: Torques and Angular Momentum
The submarine has four "hitpoints", locations where off-centre
forces can be applied. The system is presently calculating buoyant
forces for these locations, but not torques.
Calculate a torque for each hitpoint (r x F). Be VERY careful what you
use for r! The simplest thing is to use the centre of mass of the submarine
as the origin and to do calculations in the submarine's body space, but in
order to do so you need to transform the world-coordinate into body space.
Alternatively, you can transform the body coordinates into world space.
Once you have suitable torques, update L (angular momentum) and use
omega = Iinv * L to find angular velocity. Then, you have all the information
you need to update the complete state vector, including the orientation q.
Remember to renormalize your orientation quaternion at every timestep.
Part 3: Damping
You will probably notice that the system is rather unstable: the submarine
can start spinning with ever-increasing speeds. This is because the rotational
motion is not damped. Introduce damping torques.
The damping force at a point will be -k*v, for a damping constant k and linear
velocity v. The movement of a point is not the movement of the whole body!
Recall that the rotational velocity of a point (i.e., relative to the centre of mass) is omega x r. Again, remember to keep your
coordinate systems straight when you calculate r: as described, r is the
vector to the centre of mass. Once the damping forces are known, apply the
forces and torques to the body -- one for every underwater hitpoint.
Part 4: Bonus
For a bonus of up to +10%, turn the simulation into a game by trying to
keep the submarine stable despite stormy seas. At random intervals, assign
a random impulse to one of the four hitpoints of the submarine. Also, give
the user the ability to apply small known impulses to the hitpoints using
keypresses. Track how much the submarine is tipped over (vertical vector in
body coordinate frame is far from world vertical -- hint, this is the
same problem as the lander question on the midterm) and if it exceeds some
value, the game is lost. Keep score by marking how much time the player
can keep the submarine up.
Handing it in
Hand in your project using WebCT.
The easiest thing to do is to create a single zipped folder and submit
that, rather than all the individual files. It might take a while to
upload, so be prepared to take a little break while the files are in