CSCI 1300, Section 100
Hints on Assignment 5
1. Click here to download an executable that
shows you the way your program should work. Check out this cool modification of the cube program.
2. Before you begin this assignments, read the program design advice we have prepared
for you.
3. For keyboard input, check out the kbhit() and getch() functions that come
with the graphics library.
4. Keep straight in your mind that there are three differentt coordinate systems
you need to use for the assignment: (a) the three-dimensional
coordinates of vertices of the actual cube that you are modeling,
(b) the two-dimensional projection of these points in the Cartesian
coordinate system (where the origin is the center of the cube), and (c)
the two-dimensional pixel coordinate system. Internally, your
program must maintain the three dimensional coordinates of the vertices
in order to do rotations in 3D. You cannot model a 3 dimensional
object without keeping track of its 3 dimensional coordinates.
After you've modeled the position of the cube in 3D, you can then
project the 3D coordinates to 3D and then map the 2D coordinates to
pixel coordinates. Always be clear on what coordinate system you
are using at what point in your program. 2D coordinates, both
Cartesian and pixel, are needed only for displaying the object.
All internal manipulations should take place in 3D.
5. There are two ways to rotate your cube. One is to keep track
of the current vertices in 3D and update them by rotating 5 degrees
around the specified axis when the user hits a control key.
Another is to keep track of the X, Y, and Z angles by adding or
subtracting 5 degrees to the angle every time the user hits one of the
control keys, and each time you redisplay the cube, transforming the original cube by the total amount
of rotation. Because small errors in precision accumulate, it is
better to use the latter technique. If you keep rotating a point
by 5 degrees, it will not end up at exactly
the same position when you rotate it through 360 degrees due to round
off error. The angle updating approach avoids this problem.
6. If you feel confused because you didn't understand the blather about
matrix multiplication, ignore all of it and look at the equations near
the bottom of p. 2, following the text "Or, shown all at once, we
have...". The three formulas on the right side of the expression
give the new (v0,v1,v2) values based on the matrix elements mi,j
and the current (v0,v1,v2) values. The mi,j values for
different rotation and scaling transforms can be found on the bottom of
p. 2 and the top of p. 3. Note that you must use the old (v0,v1,v2) values to compute
the new values. Don't
update v0 and use the new value of v0 to update v1 and v2!