CPSE3710-Cube

Written questions

(1) Consider the intersection between two line segments L1 and L2 in 2D, where L1 is defined by two points P1 and P2 while L2 is defined by two points Q1 and Q2.

Both line segments are represented using parametric form. Suppose that u1 is the parameter for L1 and u2 is the parameter for L2 . In the class, we have discussed some situations for the intersection between the two line segments. List all the possible situations for the intersection and, for each situation, show the range of u1 and u2, respectively.

(2) Consider the graphics pipeline we have discussed in class. We understand that there are three operations in the pipeline: namely transformation, clipping, and projection, in that order. Assume that each such operation takes T time units. For a graphics application, suppose that it contains four separate vertices. Answer the following questions.

(a) If we apply sequentially the three operations (in that order) to each vertex and process all the four vertices one after another, calculate how many time units we need to process them. Show your work.

(b) Suppose that a graphic card implements the pipeline and needs T time units to conduct each operation. If we apply the pipeline in the card to process all the four vertices, calculate how many time units the card needs to process them. Show your work.

(3) Consider viewing using a rectangle, i.e., only the parts of objects inside the rectangle are visible and consider clipping a line segment using the rectangle. It turns out that we only need to consider the line segment’s endpoints in order to determine whether it is completely visible, is partially clipped, or is completely clipped. Show this is true and draw all possible situations.

(4) In program hello.c posted on the course website, find the following lines of code and answer the questions.

1
2
3
4
glutInitWindowSize (250, 250);
glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
glVertex3f (0.25, 0.25, 0.0); // V1
glVertex3f (0.75, 0.25, 0.0); // V2

(a) What does function glOrtho do?(b) Calculate the distance between the two points V1 and V2, in the unit of pixels, on the monitor.

(b) Calculate the distance between the two points V1 and V2, in the unit of pixels, on the monitor.

Programming questions

Read carefully the program control.c on the course website and try it yourself.

Also try the corresponding make file.

First delete all the callback functions for keys and special keys. Your tasks are as follows.
(a) Create a cube using glBegin(GL_QUADS) … glEnd() by modifying control.c. (Note that in the original control.c, the program only creates four QUADs and there even exist some gaps among them.) Choose any color you like for each face (QUAD) of your cube.

(b) Create a callback function myCBKey and install it. This function handles keys a and z, such that pressing a pushes the cube forward (away from you) while pressing z retreats the cube backward (back toward you). Your eye position is fixed.
Your program should be called lastname.c, where lastname is your last name. Also create a make file called lastnameMake, such that the marker can compile your program and check it.

Send lastname.c and lastnameMake to your marker through your e-mail account. The subject of your e-mail should be read: request 1, lastname. The marker’s e-mail address will be announced shortly.