CS 381, Fall 2007
HW #3
General Information
- Submit your answers to the questions, C++ source programs and screenshots
of the graphics window to Blackboard by Tuesday, October 9.
- Send source and screebshots only! No executables, project/workspace files, etc.
- Due: Tuesday, October 9 (any time).
- Worth: 20 points.
Homework Policies
See the
Homework Policies handout.
Questions (10 pts)
- Let u = (1, –1 ,2),
and let v = (0, 3 ,1).
Compute each of the following.
- 2u.
- u + v.
- u · v.
- u × v.
- Find the angle between u and v, in degrees,
to one decimal place.
- Derive the 2D rotation matrix, R(45), for a 45 degree counterclockwise
rotation of a point around the origin.
- Demonstrate the transformation by multiplying R(45) by the
point (1,1).
- Derive the 2D translation matrix T(P), which translates a point Q to the
point Q + P using homogeneous coordinates for P and Q.
Program #1 (5 pts)
Compile and run the OpenGL program double.c
- How does resizing the window affect the animation with
respect to the size and rotation speed of the square? What does myReshape()
do?
- What functions do the mouse buttons perform?
Modify the program to attach a popup menu to the left mouse button which
replaces all other button functions. The menu should have entries for "start",
"stop" and "quit".
- What variable controls the rotation speed of the square?
Modify this variable by trial and error to make the square rotate at a
speed of approximately 1 full rotation per second.
- Based on the results of (c), estimate the display update rate in frames
per second (fps) for your system. Explain your estimate.
Program #2 (5 pts)
Compile and run the OpenGL program timer.cpp.
Modify the program to display an analog clock as a circle with a radial
line representing the second hand that makes one revolution every 60 seconds.
Extra Credit:
- Add minute and hour hands drawn as narrow triangles which move at the
correct speeds.
- Label the hours on the face of the clock near the perimeter of the circle
and decorate the clock face by adding color to the face and hands of the clock.
- Initialize the clock to the system time using the time(0) function.
Note
Particularly well-done programs may be demonstrated in class.
CS 381, Fall 2007: Assignment 3 /
Last update: 2 Oct 2007