CS 184: COMPUTER GRAPHICS

Please pick up your Mini-Quiz -- sorted alphabetically by class account.

New  QUESTIONS OF THE DAY:

1.) What is the largest circle that you can display on your screen (diameter in pixels) ?

2.) You have rasterized a perfect circle into a 500 by 500 pixel square viewport,
     but now you use a different display that does not have square pixels  ==> How to avoid distortions ?

3.) How do you display a 16:9 aspect ratio movie on your old 4:3 aspect ratio screen ?



PREVIOUS < - - - - > CS 184 HOME < - - - - > CURRENT < - - - - > NEXT

NOTE: Discussion Section #3 (Tue 10-11am) has been dropped.

Lecture #6 -- Mon 2/9/2009.

2D Transformations

Last week we discussed how to construct and edit a polygon, how to determine what is inside, and how to rasterize it.
Today we talk about how to transform it::
-- first in the modeling phase to build up a scene (modeling transformation)
-- and then again to map that scene to a particular location on the display (viewport mapping).
World to screen transforms for the classical rendering pipeline.
And what it does to a world of triangles.
Transformations are a key element of computer graphics ! 

Conceptual demo of the  MODELING TRANSFORMATION  with transparency overlays: Placement, grouping, compound transformations...
e.g., rotation around an arbitrary point
e.g., synthesizing a shear transformation
note: order of transformation matters !
Now, what is going on "under the hood"?

Matrix Representation of Translations; Homogeneous Coordinates

Transformations are conveniently described and applied with the use of matrices.
This yields a powerful formalism for combining the effects of several transformations through matrix multiplication.
Also: If we transform a complicated object with thousands of vertices with the same transformation,
         then we need to calculate that compound matrix only once and can than use it to transform all those vertices.

We also want to do Translation with Matrices. This is not straight-forward, since translation is not a "linear operation"!
Linear transforms: {T(aX + B) = a T(X) + b } always leave origin in place; T(0) = 0.
--> We use a clever hack via homogeneous coordinates:
Homogenizing = introduce an extra component: w :  (x, y) ==>  (wx, wy, w)
We can recover the  regular cartesian coordinates by a division with w  (w<>0); this corresponds to a cut of the homogeneous line with the w=1 plane.
Matrix operation is still linear in d+1 dimension (origin stays in place), but we are only interested in (hyper-)plane  w=1.
The basic translation matrix, and how it works.
All 2D transformation matrices for use with homogeneous column vectors.
Distinguish: Rigid-body transforms  (rotate and translate) and  Affine transforms  (scaling and shear).

Issues arising from use of homogeneous coordinates:

Efficiency ?: -- Number of arithmetic operations may increase!
Yields ease of composition: -- No need to separate out the translation part.
Abstraction from implementation: however it is done -- hide it from user !  (also: row vectors versus column vectors =>  "outside" matrix multiplication).
Also: Now we have hardware that has been designed to handle homogeneous coordinates, thus there would be no savings doing it any other way!

Viewport Mapping

In assignment A#2 you are asked to make the display window scalable (e.g., by dragging one of its corners).
But you don't want your carefully designed fantasy polygon to be distorted -- just scale it uniformly to the largest size that fits into the given window.
Thus you have to determine what is the largest rectangle with the aspect ratio of your original drawing window (= square) that fits into the given window.
If we were to just scale the x- and y-directions individually, so that the content of window completely fills the viewport, we might get affine distortions, if the aspect ratios of window and viewport are different. To avoid such distortion, we choose the smaller of the two scale factors and apply it uniformly to both axes.

To gain independence and abstraction of the actual display device, we calculate the necessary transformation in steps: 
Window (a selected 2D piece of your original sceene) ==> NDC (normalized Device coordinates: 0,0 to 1,1 ) ==> Viewport (area on display, e.g. in pixel addresses).



Crucial Concepts from Last Lecture (and Mini-Quiz Answers):

Fill in the polygon based on "Non-Zero Winding Number". ==> Orientation plays no role! (Starting point plays no role either).
Practical hint: draw some orientation onto the polygon contour if it is not already given. Label fields with winding numbers. Check that adjacent fields differ by exactly ONE.

How many DOFs are there for the specification of all possible ...

Picking:
Find what is under the cursor!  ( Like target shooting in a CG game:  How do you know what, if anything, you hit with your blaster ? )
A#2: Test each polygon vertex whether it is "close enough" (+/- 2-3 pixels) to the mouse!

Various possible bounds:
Axis-aligned bounding boxes (AABB):  most often used, easy to compute, can be somewhat wasteful.
Optimally oriented bounding boxes (OOBB)
:  are more efficient but more difficult to determine.
Bounding circles or spheres: have rotation-independent size, but are not so easy to find either.
Convex hulls: can be constructed efficiently, but may have many vertices, --> loss of efficiency.


Scene Hierarchy, Instantiations, Compound Transformations

Now we want to build complex scenes with more than just one polygon!
How should we "describe" a complex world model in the computer ?  -- for instance: a Boeing 747: ~ 4 000 000 identifyable parts?.  -- or a battle scene in StarWars?
Use hierarchically nested groups of objects (and of other groups) with relative transformations.
An object or group of objects can be instantiated multiple times -- in different places, with different orientations, and different scales.
Benefits:  Managing complexity, abstraction, structure, re-use of objects, easy searching and editing, reducing the rendering work, ...

Hierarchical Scene Composition and Description (Houses on a Hill)

NEXT TIME ...


Reading Assignments:

Study: ( i.e., try to understand fully, so that you can answer questions on an exam): 
Shirley, 2nd Ed: Ch 6.1, 6.3.


Programming Assignment 2: 

Assignment #2 is due (electronically submitted) before Thursday 2/12, 11:00pm.

I strongly recommend that you should be done with your assignments by Wednesday,
so that you can then focus on the new one and pay attention to what I might say in class about it.
The "extension" to Thursday should only be seen as an emergency measure.


PREVIOUS < - - - - > CS 184 HOME < - - - - > CURRENT < - - - - > NEXT
Page Editor: Carlo H. Séquin