Title: Computer%20Graphics%20(Spring%202003)
1Computer Graphics (Spring 2003)
- COMS 4160, Lecture 9 Transformations 2
- Ravi Ramamoorthi
http//www.cs.columbia.edu/cs4160
2Motivation
- Modeling
- Objects in convenient coordinate system
- Transform into world space, eye space
- Viewing project world space into 2D rectangle
- Virtual cameras
- Types of projections (perspective, orthographic)
- Window system
3Rotations
- Very brief overview (not in detail)
- For little more detail, some useful websites
- www.cs.berkeley.edu/ug/slide/pipeline/assignments
/as5/rotation.html - www.cs.cmu.edu/afs/cs/academic/class/16741-s02/www
/lecture6.pdf
4Rotations
- 2D (simple)
- Matrix representation, commutative
- 3D (complicated)
- Non-commutative
- Counterclockwise
- Matrix reps for axis transforms
5Euler Angles
- Rotate about Z, then new X, then
new Z - Goldstein pp 107
- Product of axis transforms
- Efficient, 3 parameters
- Bad for numerics, splining
6Axis-Angle
- Single axis, angle about it
- 3 params (axis is normalized)
- Somewhat intuitive
- Many of same numerical problems as Euler-Angles
- Formula (axis-angle to rotation matrix)
Dual Matrix of v
7Viewing
- 3D
- Pipeline (pp 230 FvDFH)
- Projection 3D -gt 2D
- Clip near and far planes (viewing volume)
8The Whole Viewing Pipeline
Eye coordinates
Model coordinates
Perspective transformation
Model transformation
Screen coordinates
Viewport transformation
World coordinates
Camera transformation
Window coordinates
Raster transformation
Device coordinates
Slide courtesy Greg Humphreys
9Projections
- To lower dimensional space
- Preserve straight lines
- Trivial example Drop one coordinate
- We are concerned with 3D -gt 2D
- Taxonomy Fig 6.13, pp 237
- Perspective realistic images, no proportions
preserved - Parallel preserves proportions
- Orthographic (common in graphics)
10Perspective
- Center of projection, rays, projection plane
- Distance from center of projection to projection
plane is finite. If infinite, projection rays
parallel - Foreshortening Key feature
- Size inverse proportional to distance
- Cameras, visual system are similar
11Perspective or Parallel?
- If the distance between the center of
projection and the projection plane is finite,
the projection is called a perspective
projection. Otherwise, its a parallel
projection.
A
A
A
A
B
B
B
B
C (at infinity)
C
Parallel
Perspective
12Perspective
- Distortions
- Lines remain lines, everything else is distorted
- Vanishing points for parallel lines
- Shape distortions
- Parallel Projections (parallel lines are
parallel) - Not realistic but preserve size (useful in
mechanical drawings)
13Parallel (Orthographic)
- Projection vector (direction of rays)
- Perpendicular to projection plane Orthographic
- Otherwise, oblique.
- Far off objects in perspective are approx.
orthographic - Uniform foreshortening
- Parallelism preserved, angles are not
- More info in book
- We now concentrate on perspective
14Perspective mathematically 1
- Intuition divide by z
- Eye as a point (or pinhole camera)
- Easy in eye space (homogeneous coordinates)
- Simple form equation 6.4 page 255
- Full mathematics next week
15Overhead View of Our Screen
Looks like weve got some nice similar triangles
here!
Next few slides courtesy Greg Humphreys
16The Perspective Matrix
- This division by z can be accomplished by a 4x4
matrix - Were in homogeneous coordinates, so if we
multiply some point by P, we
get . - Recall that to get the actual 3D point, you
divide by w, giving ,
which was the point on our screen. Now just drop
the third coordinate!
17Viewing in OpenGL
- OpenGL has multiple matrix stacks -
transformation functions right-multiply the top
of the stack - Two most important stacks GL_MODELVIEW and
GL_PROJECTION - Points get multiplied by the modelview matrix
first, and then the projection matrix - This is only really necessary for convenience --
you could ignore all of this and put your entire
viewing matrix into one or the other. However,
if one is changing and the other one isnt,
youll save time
18OpenGL Example
void SetUpViewing() // The viewport isnt a
matrix, its just state... glViewport( 0, 0,
window_width, window_height ) // Set up camera
transformation first glMatrixMode( GL_PROJECTION
) glLoadIdentity() gluPerspective( 60, 1, 1,
1000 ) // fov, aspect, near, far gluLookAt( 3,
3, 2, // eye point 0, 0, 0,
// look at point 0, 0, 1 )
// up vector // Set up the model
transformation glMatrixMode( GL_MODELVIEW
) glRotatef( theta, 0, 0, 1 ) // rotate the
model glScalef( zoom, zoom, zoom ) // scale the
model