Presentation is loading. Please wait.

Presentation is loading. Please wait.

Computer Graphics (Spring 2003)

Similar presentations


Presentation on theme: "Computer Graphics (Spring 2003)"— Presentation transcript:

1 Computer Graphics (Spring 2003)
COMS 4160, Lecture 9: Transformations 2 Ravi Ramamoorthi

2 Motivation 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

3 Rotations Very brief overview (not in detail)
For little more detail, some useful websites:

4 Rotations 2D (simple) 3D (complicated)
Matrix representation, commutative 3D (complicated) Non-commutative Counterclockwise Matrix reps for axis transforms

5 Euler Angles Rotate about Z, then new X, then new Z [Goldstein pp 107]
Product of axis transforms Efficient, 3 parameters Bad for numerics, splining

6 Axis-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

7 Viewing 3D Pipeline (pp 230 FvDFH) Projection 3D -> 2D
Clip: near and far planes (viewing volume)

8 The Whole Viewing Pipeline
Eye coordinates Model coordinates Perspective transformation Model transformation Screen coordinates World coordinates Viewport transformation Camera transformation Window coordinates Raster transformation Device coordinates Slide courtesy Greg Humphreys

9 Projections To lower dimensional space Taxonomy [Fig 6.13, pp 237]
Preserve straight lines Trivial example: Drop one coordinate We are concerned with 3D -> 2D Taxonomy [Fig 6.13, pp 237] Perspective [realistic images, no proportions preserved] Parallel [preserves proportions] Orthographic (common in graphics)

10 Perspective 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

11 Perspective or Parallel?
If the distance between the center of projection and the projection plane is finite, the projection is called a perspective projection. Otherwise, it’s a parallel projection. A A A’ A’ B B B’ B’ C (at infinity) C Parallel Perspective

12 Perspective 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)

13 Parallel (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…

14 Perspective 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

15 Overhead View of Our Screen
Looks like we’ve got some nice similar triangles here! Next few slides courtesy Greg Humphreys

16 The Perspective Matrix
This “division by z” can be accomplished by a 4x4 matrix We’re 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!

17 Viewing 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 isn’t, you’ll save time

18 OpenGL Example void SetUpViewing() {
// The viewport isn’t a matrix, it’s 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 }


Download ppt "Computer Graphics (Spring 2003)"

Similar presentations


Ads by Google