Download presentation source

Download Report

Transcript Download presentation source

CS 551 / 645:
Introductory Computer Graphics
David Luebke
[email protected]
http://www.cs.virginia.edu/~cs551
David Luebke
7/27/2016
Administrivia

Assignment 2
–
–
–
–

Explain grading
Show some images
Show some cool demos
Hand back
Assignment 4
– Go over
David Luebke
7/27/2016
Recap: 3-D Graphics Pipeline
Transform
Illuminate
Transform
Clip
Project
Rasterize
Model & Camera
Parameters
David Luebke
Rendering Pipeline
Framebuffer
Display
7/27/2016
Recap: The Rendering Pipeline
Transform
Illuminate
Transform
Clip
Project
Rasterize
Model & Camera
Parameters
David Luebke
Rendering Pipeline
Framebuffer
Display
7/27/2016
Recap: Rendering Pipeline (2-D)
Transform
Illuminate
Transform
Clip
Project
Rasterize
Model & Camera
Parameters
David Luebke
Rendering Pipeline
Framebuffer
Display
7/27/2016
Recap: Rendering Pipeline (3-D)
Transform
Illuminate
Transform
Clip
Project
Rasterize
Model & Camera
Parameters
David Luebke
Rendering Pipeline
Framebuffer
Display
7/27/2016
Recap: Rendering Pipeline (3-D)
Scene graph
Object geometry
Result:
Modeling
Transforms
• All vertices of scene in shared 3-D “world” coordinate system
Lighting
Calculations
• Vertices shaded according to lighting model
Viewing
Transform
• Scene vertices in 3-D “view” or “camera” coordinate system
Clipping
Projection
Transform
David Luebke
• Exactly those vertices & portions of polygons in view frustum
• 2-D screen coordinates of clipped vertices
7/27/2016
Recap: Transformations

Modeling transforms
– Size, place, scale, and rotate objects parts of the
model w.r.t. each other
– Object coordinates  world coordinates
Y
Y
X
Z
X
Z
David Luebke
7/27/2016
Recap: Transformations

Viewing transform
– Rotate & translate the world to lie directly in front of
the camera


Typically place camera at origin
Typically looking down -Z axis
– World coordinates  view coordinates
David Luebke
7/27/2016
Recap: Transformations

Projection transform
– Apply perspective foreshortening

Distant = small: the pinhole camera model
– View coordinates  screen coordinates
David Luebke
7/27/2016
Rigid-Body Transforms


Goal: object coordinatesworld coordinates
Idea: use only transformations that preserve
the shape of the object
– Rigid-body or Euclidean transforms
– Includes rotation, translation, and scale

To reiterate: we will represent points as
column vectors:
 x


( x, y , z )   y 
 z 
David Luebke
7/27/2016
Vectors and Matrices

Vector algebra operations can be expressed
in this matrix form
– Dot product:
– Cross product:

Note: use
right-hand
rule!
a  b  ax ay
bx 
az by   
bz 
 0  az ay  bx  cx 
a  b   az
0  ax  by   cy   c
 ay ax
0  bz  cz 
ac  0
bc  0
David Luebke
7/27/2016
Translations

For convenience we usually describe objects
in relation to their own coordinate system
– Solar system example

We can translate or move points to a new
position by adding offsets to their coordinates:
 x'  x  tx 
 y '   y   ty 
     
 z '   z  tz 
– Note that this translates all points uniformly
David Luebke
7/27/2016
Scaling


Scaling a coordinate means multiplying each
of its components by a scalar
Uniform scaling means this scalar is the
same for all components:
2
David Luebke
7/27/2016
Scaling

Non-uniform scaling: different scalars per
component:
X  2,
Y  0.5

How can we represent this in matrix form?
David Luebke
7/27/2016
Scaling

Scaling operation:

Or, in matrix form:
 x' ax 
 y '  by 
   
 z '   cz 
 x '   a 0 0  x 
 y'  0 b 0  y 
  
 
 z '  0 0 c   z 
scaling matrix
David Luebke
7/27/2016
3-D Rotations

Rotations in 2-D are easy:

3-D is more complicated
 x' cos  sin   x 
 y '   sin  cos   y 
  
 
– Need to specify an axis of rotation
– Common pedagogy: express rotation about this
axis as the composition of canonical rotations

David Luebke
Canonical rotations: rotation about X-axis, Y-axis, Z-axis
7/27/2016
3-D Rotations

Basic idea:
– Using rotations about X, Y, Z axes, rotate model
until desired axis of rotation coincides with Z-axis
– Perform rotation in the X-Y plane (i.e., about Z-axis)
– Reverse the initial rotations to get back into the
initial frame of reference

Objections:
– Difficult & error prone
– Ambiguous: several combinations about the
canonical axis give the same result
– For a different approach, see McMillan’s lecture 12
David Luebke
7/27/2016
Next Up:

Next up: homogeneous coordinates
David Luebke
7/27/2016