15-462 Computer Graphics I
Assignment 5 - Camera Movement


The best way we've seen to keep track of your camera coordinate systems is by Ken Sloan, summarized below. If you didn't keep track of your coordinate system from position to position along the spline, then your up vector would point in an arbitratry direction each time. This might cause your camera to rotate unpredictably as it moved along the spline.

Camera Coordinates

So we'll keep track of the coordinate system by using the previous coordinate system that you defined in order to generate your new one. For every point P along the spline, you will need to define 3 vectors, T (tangent), N (normal), and B (binormal).

The first thing you need to do is generate a starting set of axes at P0. Since you already have the T0 vector which is just the tangent vector of the spline at that point. You can pick some arbitrary vector M. Then make N0=unit(T0xM) and B0=unit(T0xN0). Now that you have T0, N0, and B0 you have the coordinate system for P0. Here write write unit(v) for the normalized vector v/|v|.

Next you have to calculate a coordinate system for P1. Since you already have T1, N1=unit(B0xT1) and B1=unit(T1xN1). This process is repeated along every point along the spline so that your coordinate system will always stay consistent.


There are two areas of the lab where this comes into use. The first is obviously the camera, you can use the coordinate system to orient the camera properly. The second use is when deciding the orientation of the cross sections when drawing them. To orient a cross section you need to create a transformation matrix which will move your tie to the correct position. Such a matrix mat can be constructed from T, N, B, and P.

Just as a reminder, OpenGL reads matrices in a transposed form as described in the OpenGL primer. You would want to add this matrix to the transformation before drawing your cross section rail. For example,



  • Back to Assignment 5

[ Home | Schedule | Assignments | Software | Resources ]

Frank Pfenning