## CS 435 Autumn 2000 --- Introduction to Interactive Graphics

David S. Ebert

As the lab handout mentions, the COP (PRP) is in world coordinates in the data files, our model assumes it is in VRC coordinates. You need to convert it. The following will do it:

where Rx, Ry, and Rz are the basis of the VRC in world coordinates (see pg 7-20 of the notes), the components of the R matrix.

### Window to Viewport Transformation

The transformation by results in a canonical view volume with the projection plane now being a square, with sides of length . At this point, the original window has been transformed into a square. The window-to-viewport transformation needs to get it back to it's original shape.

Think of this as a 2 step process:

1. Use the size of the window given in the input file and the drawing area on the Edge display to calculate the size of the viewport:
1. Calculate
2. This is now used to get the height and width of the viewport, knowing that the size of the drawing area is 600x500 (600/500 = 1.2) -- assumes a 50 pixel blank border.
3. If then .
4. Else .
5. Given this height and width, calculate viewport boundaries as follows:
2. The ``new window'' in the window to viewport transformation is the transformed window on the projection plane: , , , . The viewport is specified by the above calculated .

### What order should we do things in?

The general order of operations for your lab should be the following:
1. Read in the input file.
2. Calculate T(-vrp) and R
3. Save a copy of COP in world space for backface and lighting calculations.
4. Calculate COP(also called PRP) in VRC coordinates.
5. Calculate T(-prp).
6. Calculate vrp'
7. Calculate Sh and Sc, remember that CW has a z component of 0 and DOP = CW-PRP(after R & T(-vrp)).
8. Calculate Nper = Sc*SH*T(-prp)*R*T(-vrp). (all of these are 4x4 matrices)
9. Calculate
10. Calculate Window to viewport transformation.
11. Calculate Mper with d = zproj.
12. Initialize Transform = Identity
13. Loop for each rotation and scale the user clicks on
1. Calculate the rotation or Scale matrix for rotation/scale about the axis that was specified, call it T1.
2. Set Transform = T1*Transform
3. Transform points to world space, then to normalized canonical view volume: .

Or, if doing illumination and backface rejection, Transform to world space, backface reject, calculate illumination, then transform to normalized canonical view volume.

4. Clip points
5. Transform by Mper.
6. Divide by w.
7. Perform window to viewport mapping.

David Ebert