CIS 41
Computer Graphics
Chapter 4 - Geometric Objects and Transformations


Goals

The Basic Elements of Geometric Objects

Scalars

Vectors / Vector Spaces

Points / Affine Spaces

Linear (In)dependence

Basis

Coordinate Systems

  • The vectors of a basis form a coordinate system.

    Frames

    Moving from Vectors to Numbers

    Given
    v = α1e1 + α2e2 + α3e3 
    		
    where e1, e2, e3 form the basis, the representations of e1, e2, e3 themselves (with respect to e1, e2, e3) is:
    e1 = (1, 0, 0)
    e2 = (0, 1, 0)
    e3 = (0, 0, 1)
    	 
  • manipulating sequences of numbers (tuples) is easier and more efficient than trying to work with some other representation of a vector

    Changing Coordinate Systems

    Changing Representations of Vectors

    Ok, Now What-- What Does this Leave us With?

  • Matrices and Matrix Multiplication

    Trying to get a feel for a (2D) Matrix

    Suppose we have a matrix:
    		 
    | γ11 γ12|
    | γ21 γ22|
    	
    
    and we multiply it by the two standard basis vectors
    		 
    |1 0| | γ11 γ12|  -> | γ11 γ12|   
          | γ21 γ22|
    	
    
    and
    		 
    |0 1| | γ11 γ12|  -> | γ21 γ22|   
          | γ21 γ22|
    	
    
    we thus see that the rows of the matrix correspond to the standard basis vectors after the transformation represented by the matrix.

    We can visualize the effect of the matrix. The following shows the effect of the matrix

    		 
    |2  1|
    |-1 2|
    	
    		

    Frames in OpenGL

    Frame changes, as it turns out, are central to what we want from the graphic pipeline.

    Returning to the (relative) coordinates that appear in the pipeline:

    Model-View Transformations

    Tracing this sequence in more detail:

    Each of the above change of frames is represented by a transformation matrix Projection Transformations

    At this point a further set of projection transformations occur:

    Affine Transformations

    The Basic Transformations

    Translation

    Rotation

    Rigid body Transformations Scaling

    Homogeneous Coordinates Rotation

    | cos θ   -sin θ  0 | 
    | sin θ   cos θ   0 |     
    | 0       0       1 |
    			
    | cos θ   -sin θ  0   0 | 
    | sin θ   cos θ   0   0 |     Rotation around z-axis
    | 0       0       1   0 |
    | 0       0       0   1 |
    			
    | 1      0       0    0 |
    | 0  cos θ   -sin θ   0 |
    | 0  sin θ    cos θ   0 |     Rotation around x-axis
    | 0       0       0   1 |
    			
    | cos θ   0   -sin θ   0 |
    | 0       1        0   0 |       Rotation around y-axis
    | sin θ   0    cos θ   0 |     
    | 0       0       0    1 |
    			
    Scaling
    | Sx   0  0 |
    | 0    Sy 0 |
    |0     0  1 |
    				
    | Sx   0   0   0 |
    | 0    Sy  0   0 |
    | 0    0   Sz  0 |
    | 0    0   0   1 |
    				
    Translation
    | 1  0  dx |
    | 0  1  dy |
    | 0  0  1  |
    			
    | 1  0  0  dx |
    | 0  1  0  dy |
    | 0  0  1  dz |
    | 0  0  0   1 |
    			

    Transformations in OpenGL

    The OpenGL Transformation Functions

    Thinking About Transformations

    Thinking of Everything Relative to a World Coordinate System)

    Thinks of an Object's Local Coordinate System

    The code for both remains the same-- the difference is how you visualize the transformations!


    So... If They're Both the Same, How are They Different?

    Read the Section Viewing and Modeling Transformations / Thinking about Transformations int Chapter 3 of the Redbook

    The Planetary System Application

    The ModelView Matrix The gluLookAt Function

    The Projection Matrix

    Orthographic Projection - The glOrtho Function
    The Object-Oriented Version

  • Object-oriented version uses example of an instance transform

    The Robot Arm

    The Spinning Color Cube

    More on Smooth Shading

    The Trackball Application

    Code for Chapter 4