cbe0b7a184fbe89be36e3c2c36f57dc7.ppt

- Количество слайдов: 50

CIS 636 Introduction to Computer Graphics CG Basics 4 of 8: Detailed Introduction to Viewing William H. Hsu Department of Computing and Information Sciences, KSU KSOL course pages: http: //snipurl. com/1 y 5 gc Course web site: http: //www. kddresearch. org/Courses/CIS 636 Instructor home page: http: //www. cis. ksu. edu/~bhsu Readings: Slides based on Viewing 1 -3, http: //www. cs. brown. edu/courses/cs 123/lectures. htm Sections 2. 6 – 2. 7, Eberly 2 e – see http: //snurl. com/1 ye 72 Open. GL API Documentation: http: //www. opengl. org/documentation/ Lab 2: gl. Frustum(), glu. Perspective() (http: //snurl. com/1 zt 6 z) CIS 636/736: (Introduction to) Computer Graphics CG Basics 4 of 8: Viewing Computing & Information Sciences Kansas State University

Online Recorded Lectures for CIS 636 Introduction to Computer Graphics l Project Topics for CIS 636 l Computer Graphics Basics (8) 1. Mathematical Foundations – Week 2 2. Rasterizing and 2 -D Clipping – Week 3 3. Open. GL Primer 1 of 3 – Week 3 4. Detailed Introduction to 3 -D Viewing – Week 4 5. Open. GL Primer 2 of 3 – Week 5 6. Polygon Rendering – Week 6 7. Open. GL Primer 3 of 3 – Week 8 8. Visible Surface Determination – Week 9 l Recommended Background Reading for CIS 636 l Shared Lectures with CIS 736 (Computer Graphics) Regular in-class lectures (35) and labs (7) Guidelines for paper reviews – Week 7 Preparing term project presentations, demos for graphics – Week 11 CIS 636/736: (Introduction to) Computer Graphics CG Basics 4 of 8: Viewing Computing & Information Sciences Kansas State University

Lecture Outline l History of Projections l Normalizing and Viewing Transformations l Perspective (to Parallel) Transformation l Kinds of Projections Parallel ð Orthographic: top, front, side, other ð Axonometric: isometric, dimetric, trimetric ð Oblique: cavalier, cabinet ð Other Perspective: 1 -point, 2 -point, 3 -point l Viewing in Open. GL CIS 636/736: (Introduction to) Computer Graphics CG Basics 4 of 8: Viewing Computing & Information Sciences Kansas State University

From 3 -D to 2 -D: Orthographic and Perspective Projection – Part 1 l History l Geometrical Constructions l Types of Projection l Projection in Computer Graphics Adapted from slides for Brown University CS 123, Computer Graphics © 2000 – 2007, A. van Dam. Used with permission. CIS 636/736: (Introduction to) Computer Graphics CG Basics 4 of 8: Viewing Computing & Information Sciences Kansas State University

Logical Relationship among Types of Projections l Parallel projections used for engineering and architecture because they can be used for measurements l Perspective imitates our eyes or camera, looks more natural Adapted from slides for Brown University CS 123, Computer Graphics © 2000 – 2007, A. van Dam. Used with permission. CIS 636/736: (Introduction to) Computer Graphics CG Basics 4 of 8: Viewing Computing & Information Sciences Kansas State University

Axonometric Projections l Same method as multiview orthographic projections, except projection plane not parallel to any of the coordinate planes; parallel lines are equally foreshortened l Isometric: Angles between all three principal axes are equal (120º). The same scale ratio applies along each axis l Dimetric: Angles between two of the principal axes are equal; need two scale ratios l Trimetric: Angles different between the three principal axes; need three scale ratios l Note: different names for different views, but all part of a continuum of parallel projections of the cube; these differ in where the projection plane is relative to its cube dimetric isometric dimetric orthographic Carlbom Fig. 3 -8 Adapted from slides for Brown University CS 123, Computer Graphics © 2000 – 2007, A. van Dam. Used with permission. CIS 636/736: (Introduction to) Computer Graphics CG Basics 4 of 8: Viewing Computing & Information Sciences Kansas State University

Isometric Projection: Special Case of Axonometric l Used for: catalogue illustrations patent office records furniture design structural design l Pros: don’t need multiple views illustrates 3 D nature of object measurements can be made to scale along principal axes l Cons: lack of foreshortening creates distorted appearance more useful for rectangular than curved shapes Example Construction of isometric projection: projection plane cuts each principal axis by 45° Carlbom Fig. 2. 2 Adapted from slides for Brown University CS 123, Computer Graphics © 2000 – 2007, A. van Dam. Used with permission. CIS 636/736: (Introduction to) Computer Graphics CG Basics 4 of 8: Viewing Computing & Information Sciences Kansas State University

Oblique Projections l Projectors are at an oblique angle to the projection plane; view cameras have accordion housing, used for skyscrapers l Pros: can present the exact shape of one face of an object (can take accurate measurements): better for elliptical shapes than axonometric projections, better for “mechanical” viewing lack of perspective foreshortening makes comparison of sizes easier displays some of object’s 3 D appearance l Cons: objects can look distorted if careful choice not made about position of projection plane (e. g. , circles become ellipses) lack of foreshortening (not realistic looking) perspective oblique Adapted from slides for Brown University CS 123, Computer Graphics © 2000 – 2007, A. van Dam. Used with permission. CIS 636/736: (Introduction to) Computer Graphics CG Basics 4 of 8: Viewing Computing & Information Sciences Kansas State University

View Camera Source: http: //www. usinternet. com/users/rniederman/star 01. htm Adapted from slides for Brown University CS 123, Computer Graphics © 2000 – 2007, A. van Dam. Used with permission. CIS 636/736: (Introduction to) Computer Graphics CG Basics 4 of 8: Viewing Computing & Information Sciences Kansas State University

Examples of Oblique Projections Construction of an oblique parallel projection (Carlbom Fig. 2 -6) Plan oblique projection of a city (Carlbom Fig. 2 -4) Front oblique projection of a radio Adapted from slides for Brown University CS 123, Computer Graphics © 2000 – 2007, A. van Dam. Used with permission. CIS 636/736: (Introduction to) Computer Graphics CG Basics 4 of 8: Viewing Computing & Information Sciences Kansas State University

Example and Principles: Oblique View l Rules for placing projection plane for oblique views l Projection plane should be set parallel to one of: most irregular of principal faces, or one which contains circular or curved surfaces longest principal face of object face of interest Projection plane parallel to circular face Projection plane not parallel to circular face Adapted from slides for Brown University CS 123, Computer Graphics © 2000 – 2007, A. van Dam. Used with permission. CIS 636/736: (Introduction to) Computer Graphics CG Basics 4 of 8: Viewing Computing & Information Sciences Kansas State University

Main Types of Oblique Projections l Cavalier: Angle between projectors and projection plane is 45º. Perpendicular faces are projected at full scale cavalier projection of unit cube l Cabinet: Angle between projectors and projection plane is arctan(2) = 63. 4º. Perpendicular faces are projected at 50% scale cabinet projection of unit cube Adapted from slides for Brown University CS 123, Computer Graphics © 2000 – 2007, A. van Dam. Used with permission. CIS 636/736: (Introduction to) Computer Graphics CG Basics 4 of 8: Viewing Computing & Information Sciences Kansas State University

Examples of Orthographic and Oblique Projections multiview orthographic cavalier cabinet Adapted from slides for Brown University CS 123, Computer Graphics © 2000 – 2007, A. van Dam. Used with permission. CIS 636/736: (Introduction to) Computer Graphics CG Basics 4 of 8: Viewing Carlbom Fig. 3 -2 Computing & Information Sciences Kansas State University

Parallel Projections: Summary l Assume object face of interest lies in principal plane, i. e. , parallel to xy, yz, or zx planes. (DOP = Direction of Projection, VPN = View Plane Normal) 1) Multiview Orthographic – VPN || a principal coordinate axis – DOP || VPN – shows single face, exact measurements 2) Axonometric – VPN || a principal coordinate axis – DOP || VPN – adjacent faces, none exact, uniformly foreshortened (as a function of angle between face normal and DOP) 3) Oblique – VPN || a principal coordinate axis – DOP || VPN – adjacent faces, one exact, others uniformly foreshortened Adapted from slides for Brown University CS 123, Computer Graphics © 2000 – 2007, A. van Dam. Used with permission. CIS 636/736: (Introduction to) Computer Graphics CG Basics 4 of 8: Viewing Computing & Information Sciences Kansas State University

Perspective Projections l Used for: advertising presentation drawings for architecture, industrial design, engineering fine art l Pros: gives a realistic view and feeling for 3 D form of object l Cons: does not preserve shape of object or scale (except where object intersects projection plane) l Different from a parallel projection because parallel lines not parallel to the projection plane converge size of object is diminished with distance foreshortening is not uniform Adapted from slides for Brown University CS 123, Computer Graphics © 2000 – 2007, A. van Dam. Used with permission. CIS 636/736: (Introduction to) Computer Graphics CG Basics 4 of 8: Viewing Computing & Information Sciences Kansas State University

Vanishing Points [1] l For right-angled forms whose face normals are perpendicular to the x, y, z coordinate axes, the number of vanishing points = number of principal coordinate axes intersected by projection plane One Point Perspective (z-axis vanishing point) z Three Point Perspective (z, x, and y-axis vanishing points) Two Point Perspective (z, and x-axis vanishing points) Adapted from slides for Brown University CS 123, Computer Graphics © 2000 – 2007, A. van Dam. Used with permission. CIS 636/736: (Introduction to) Computer Graphics CG Basics 4 of 8: Viewing Computing & Information Sciences Kansas State University

Vanishing Points [2] l What happens if same form is turned so that its face normals are not perpendicular to x, y, z coordinate axes? • New viewing situation: cube rotated, face normals no longer perpendicular to any principal axes • Note: unprojected cube depicted here with parallel projection • Although projection plane only intersects one axis (z), three vanishing points were created • Perspective drawing of rotated cube Note: can achieve final results which are identical to previous situation in which projection plane intersected all three axes Adapted from slides for Brown University CS 123, Computer Graphics © 2000 – 2007, A. van Dam. Used with permission. CIS 636/736: (Introduction to) Computer Graphics CG Basics 4 of 8: Viewing Computing & Information Sciences Kansas State University

Vanishing Points and View Point [1] l We’ve seen two pyramid geometries for understanding perspective projection: 1. perspective image is intersection of a plane with light rays from object to eye (COP) 2. perspective image is result of foreshortening due to convergence of some parallel lines toward vanishing points l Combining these 2 views: Adapted from slides for Brown University CS 123, Computer Graphics © 2000 – 2007, A. van Dam. Used with permission. CIS 636/736: (Introduction to) Computer Graphics CG Basics 4 of 8: Viewing Computing & Information Sciences Kansas State University

Vanishing Points and View Point [2] l Project parallel lines AB, CD on xy plane l Projectors from the eye to AB and CD define two planes, which meet in a line which contains the view point, or eye l This line does not intersect the projection plane (XY), because parallel to it. Therefore there is no vanishing point Adapted from slides for Brown University CS 123, Computer Graphics © 2000 – 2007, A. van Dam. Used with permission. CIS 636/736: (Introduction to) Computer Graphics CG Basics 4 of 8: Viewing Computing & Information Sciences Kansas State University

Vanishing Points and View Point [3] l Lines AB and CD (this time with A and C behind projection plane) projected on xy plane: A’B and C’D l Note: A’B not parallel to C’D l Projectors from eye to A’B and C’D define two planes which meet in a line containing view point l This line intersects projection plane l Point of intersection is vanishing point A C Adapted from slides for Brown University CS 123, Computer Graphics © 2000 – 2007, A. van Dam. Used with permission. CIS 636/736: (Introduction to) Computer Graphics CG Basics 4 of 8: Viewing Computing & Information Sciences Kansas State University

Aspect Ratio NTSC 4: 3 HDTV 16: 9 Analogous to size of film used in a camera Determines proportion of width to height of image displayed on screen Square viewing window has aspect ratio of 1: 1 Movie theater “letterbox” format has aspect ratio of 2: 1 NTSC television has aspect ratio of 4: 3, HDTV is 16: 9 Kodak l l l Adapted from slides for Brown University CS 123, Computer Graphics © 2000 – 2007, A. van Dam. Used with permission. CIS 636/736: (Introduction to) Computer Graphics CG Basics 4 of 8: Viewing Computing & Information Sciences Kansas State University

View Angle [1] l Determines amount of perspective distortion in picture parallel projection: none wide-angle lens: lots l In a frustum, two viewing angles Width and height angles We specify Height angle Get Width angle from Aspect ratio * Height angle l Choosing View angle Analogous to photographer choosing a specific type of lens e. g. , wide-angle or telephoto (narrow angle) lens Adapted from slides for Brown University CS 123, Computer Graphics © 2000 – 2007, A. van Dam. Used with permission. CIS 636/736: (Introduction to) Computer Graphics CG Basics 4 of 8: Viewing Computing & Information Sciences Kansas State University

View Angle [2] l Lenses made for distance shots often have a nearly parallel viewing angle and cause little perspective distortion, though they foreshorten depth l Wide-angle lenses cause a lot of perspective distortion Resulting pictures Adapted from slides for Brown University CS 123, Computer Graphics © 2000 – 2007, A. van Dam. Used with permission. CIS 636/736: (Introduction to) Computer Graphics CG Basics 4 of 8: Viewing Computing & Information Sciences Kansas State University

“Where’s My Film? ” Real cameras have a roll of film that captures pictures l Synthetic camera “film” is a rectangle on an infinite film plane that contains image of scene l Why haven’t we talked about the “film” in our synthetic camera, other than mentioning its aspect ratio? l How is the film plane positioned relative to the other parts of the camera? Does it lie between the near and far clipping planes? Behind them? l Turns out that fine positioning of Film plane doesn’t matter. Here’s why: for a parallel view volume, as long as the film plane lies in front of the scene, parallel projection onto film plane will look the same no matter how far away film plane is from scene same is true for perspective view volumes, because the last step of computing the perspective projection is a transformation that stretches the perspective volume into a parallel volume l In general, it is convenient to think of the film plane as lying at the eye point (Position) Adapted from slides for Brown University CS 123, Computer Graphics © 2000 – 2007, A. van Dam. Used with permission. CIS 636/736: (Introduction to) Computer Graphics CG Basics 4 of 8: Viewing Computing & Information Sciences Kansas State University

Focal Length l l l Some camera models take a Focal length Focal Length is a measure of ideal focusing range; approximates behavior of real camera lens Objects at distance of Focal length from camera are rendered in focus; objects closer or farther away than Focal length get blurred Focal length used in conjunction with clipping planes Only objects within view volume are rendered, whether blurred or not. Objects outside of view volume still get discarded Adapted from slides for Brown University CS 123, Computer Graphics © 2000 – 2007, A. van Dam. Used with permission. CIS 636/736: (Introduction to) Computer Graphics CG Basics 4 of 8: Viewing Computing & Information Sciences Kansas State University

Limitations of this Camera Model l Can create the following view volumes: perspective: positive view angle parallel: zero view angle l Cannot create oblique view volume l Non-oblique vs. oblique view volumes: Non-oblique view volume: Look vector perpendicular to film plane Oblique view volume: Look vector at an angle to film plane l For example, view cameras with bellows are used to take pictures of (tall) buildings. l Film plane is parallel to the façade, while camera points up l This is oblique view volume, with façade undistorted Adapted from slides for Brown University CS 123, Computer Graphics © 2000 – 2007, A. van Dam. Used with permission. CIS 636/736: (Introduction to) Computer Graphics CG Basics 4 of 8: Viewing Computing & Information Sciences Kansas State University

References l Carlbom, Ingrid and Paciorek, Joseph, “Planar Geometric Projections and Viewing Transformations, ” Computing Surveys, Vol. 10, No. 4 December 1978 l Kemp, Martin, The Science of Art, Yale University Press, 1992 l Mitchell, William J. , The Reconfigured Eye, MIT Press, 1992 l Foley, van Dam, et. al. , Computer Graphics: Principles and Practice, Addison-Wesley, 1995 l Wernecke, Josie, The Inventor Mentor, Addison-Wesley, 1994 Adapted from slides for Brown University CS 123, Computer Graphics © 2000 – 2007, A. van Dam. Used with permission. CIS 636/736: (Introduction to) Computer Graphics CG Basics 4 of 8: Viewing Computing & Information Sciences Kansas State University

Projection in Computer Graphics Adapted from slides for Brown University CS 123, Computer Graphics © 2000 – 2007, A. van Dam. Used with permission. CIS 636/736: (Introduction to) Computer Graphics CG Basics 4 of 8: Viewing Computing & Information Sciences Kansas State University

Look and Up Vectors l More concrete way to say the same thing as orientation soon you’ll learn how to express orientation in terms of Look and Up vectors l Look Vector the direction the camera is pointing three degrees of freedom; can be any vector in 3 -space l Up Vector determines how the camera is rotated around the Look vector for example, whether you’re holding the camera horizontally or vertically (or in between) projection of Up vector must be in the plane perpendicular to the look vector (this allows Up vector to be specified at an arbitrary angle to its Look vector) projection of Up vector Look vector Position Adapted from slides for Brown University CS 123, Computer Graphics © 2000 – 2007, A. van Dam. Used with permission. CIS 636/736: (Introduction to) Computer Graphics CG Basics 4 of 8: Viewing Computing & Information Sciences Kansas State University

Clipping: Parametric Clipping, Review l D = P 1 – P 0 = (x 1 – x 0, y 1 – y 0) l Leave PEi as an arbitrary point on the clip edge; it’s a free variable and drops out Calculations for Parametric Line Clipping Algorithm Clip Edgei Normal Ni PEi P 0 -PEi left: x = xmin (-1, 0) (xmin, y) (x 0 - xmin, y 0 -y) right: x = xmax (1, 0) (xmax, y) (x 0 - xmax, y 0 -y) bottom: y = ymin (0, -1) (x, ymin) (x 0 -x, y 0 - ymin) top: y = ymax (0, 1) (x, ymax) (x 0 -x, y 0 - ymax) Adapted from slides for Brown University CS 123, Computer Graphics © 2000 – 2007, A. van Dam. Used with permission. CIS 636/736: (Introduction to) Computer Graphics CG Basics 4 of 8: Viewing Computing & Information Sciences Kansas State University

Clipping: Front and Back Clipping Planes [1] l Volume of space between Front and Back clipping planes defines what camera can see l Position of planes defined by distance along Look vector l Objects appearing outside of view volume don’t get drawn l Objects intersecting view volume get clipped Front clipping plane Back clipping plane Adapted from slides for Brown University CS 123, Computer Graphics © 2000 – 2007, A. van Dam. Used with permission. CIS 636/736: (Introduction to) Computer Graphics CG Basics 4 of 8: Viewing Computing & Information Sciences Kansas State University

Clipping: Front and Back Clipping Planes [2] l Reasons for Front (near) clipping plane: l Don’t want to draw things too close to the camera would block view of rest of scene objects would be prone to distortion l Don’t want to draw things behind camera wouldn’t expect to see things behind the camera in the case of perspective camera, if we decided to draw things behind camera, they would appear upside-down and inside-out because of perspective transformation l Reasons for Back (far) clipping plane: l Don’t want to draw objects too far away from camera distant objects may appear too small to be visually significant, but still take long time to render by discarding them we lose a small amount of detail but reclaim a lot of rendering time alternately, scene may be filled with many significant objects for visual clarity, we may wish to declutter scene by rendering those nearest camera and discarding rest Adapted from slides for Brown University CS 123, Computer Graphics © 2000 – 2007, A. van Dam. Used with permission. CIS 636/736: (Introduction to) Computer Graphics CG Basics 4 of 8: Viewing Computing & Information Sciences Kansas State University

Clipping: Front and Back Clipping Planes [3] l l Have you ever played a video game and all of the sudden some object pops up in the background (e. g. a tree in a racing game)? That’s the object coming inside the far clip plane. The old hack to keep you from noticing the pop-up is to add fog in the distance. A classic example of this is from Turok: Dinosaur Hunter Then (1997) Now (2008) l l l Now all you notice is fog and how little you can actually see. This practically defeats the purpose of an outdoor environment! And you can still see pop-up from time to time. Thanks to fast hardware and level of detail algorithms, we can push the far plane back now and fog is much less prevalent Putting the near clip plane as far away as possible helps Z precision. Sometimes in a game you can position the camera in the right spot so that the front of an object gets clipped letting you see inside of it. Adapted from slides for Brown University CS 123, Computer Graphics © 2000 – 2007, A. van Dam. Used with permission. CIS 636/736: (Introduction to) Computer Graphics CG Basics 4 of 8: Viewing Computing & Information Sciences Kansas State University

View Volume Specification l From Position, Look vector, Up vector, Aspect ratio, Height angle, Clipping planes, and (optionally) Focal length together specify a truncated view volume l Truncated view volume is a specification of bounded space that camera can “see” l 2 D view of 3 D scene can be computed from truncated view volume and projected onto film plane l Truncated view volumes come in two flavors: parallel and perspective Adapted from slides for Brown University CS 123, Computer Graphics © 2000 – 2007, A. van Dam. Used with permission. CIS 636/736: (Introduction to) Computer Graphics CG Basics 4 of 8: Viewing Computing & Information Sciences Kansas State University

for Orthographic Parallel Projection l Limiting view volume useful for eliminating extraneous objects l Orthographic parallel projection has width and height view angles of zero Width Far distance Look vector Height Near distance Up vector Position Adapted from slides for Brown University CS 123, Computer Graphics © 2000 – 2007, A. van Dam. Used with permission. CIS 636/736: (Introduction to) Computer Graphics CG Basics 4 of 8: Viewing Computing & Information Sciences Kansas State University

Truncated View Volume (Frustum) for Perspective Projection l Removes objects too far from Position Otherwise would merge into “blobs” l Removes objects too close to Position Would be excessively distorted Width angle = Height angle • Aspect ratio Up vector Look vector Height angle Position Near distance Far distance Adapted from slides for Brown University CS 123, Computer Graphics © 2000 – 2007, A. van Dam. Used with permission. CIS 636/736: (Introduction to) Computer Graphics CG Basics 4 of 8: Viewing Computing & Information Sciences Kansas State University

Stage One: Specifying a View Volume l Reduce degrees of freedom l Five steps to specifying view volume l 1. Position the camera and therefore its view/film plane l 2. Point it at what you want to see with camera in desired orientation l 3. Define the field of view for a perspective view volume, aspect ratio of film and angle of view: somewhere between wide angle, normal, and zoom for a parallel view volume, width and height) l 4. Choose perspective or parallel projection l 5. Determine focal distance Adapted from slides for Brown University CS 123, Computer Graphics © 2000 – 2007, A. van Dam. Used with permission. CIS 636/736: (Introduction to) Computer Graphics CG Basics 4 of 8: Viewing Computing & Information Sciences Kansas State University

Specifying a View Volume l Placement of view volume (visible part of world) specified by camera’s position and orientation Position (a point) Look and Up vectors l Shape of view volume specified by horizontal and vertical view angles front and back clipping planes l l l Perspective projection: projectors intersect at Position Parallel projection: projectors parallel to Look vector, but never intersect (or intersect at infinity) Coordinate Systems world coordinates – standard right-handed xyz 3 -space viewing reference coordinates – camera-space right handed coordinate system (u, v, n); origin at Position and axes rotated by orientation; used for transforming arbitrary view into canonical view Adapted from slides for Brown University CS 123, Computer Graphics © 2000 – 2007, A. van Dam. Used with permission. CIS 636/736: (Introduction to) Computer Graphics CG Basics 4 of 8: Viewing Computing & Information Sciences Kansas State University

Arbitrary View Volume too Complex l We have now specified an arbitrary view using our viewing parameters l Problem: map arbitrary view specification to 2 D picture of scene. This is hard, both for clipping and for projection l Solution: reduce to a simpler problem and solve – Need: View specification from which it is easy to take pictures – Canonical view: from the origin, looking down negative z-axis v up u – think of the scene as lying behind window and we’re looking through the window n – parallel projection – sits at origin: Position = (0, 0, 0) – looks along negative z-axis: Look vector = (0, 0, – 1) – oriented upright: Up vector = (0, 1, 0) – film plane extending from – 1 to 1 in x and y l Note: Look vector along negative, not positive, z-axis is arbitrary but makes math easier Adapted from slides for Brown University CS 123, Computer Graphics © 2000 – 2007, A. van Dam. Used with permission. CIS 636/736: (Introduction to) Computer Graphics CG Basics 4 of 8: Viewing Computing & Information Sciences Kansas State University

Normalizing to Canonical View Volume l Our goal is to transform our arbitrary view and the world to the canonical view volume, maintaining the relationship between view volume and world, then take picture for parallel view volume, transformation is affine: made up of translations, rotations, and scales in the case of a perspective view volume, it also contains a non-affine † perspective transformation that frustum into a parallel view volume, a cuboid the composite transformation that will transform the arbitrary view volume to the canonical view volume, named the normalizing transformation, is still a 4 x 4 homogeneous coordinate matrix that typically has an inverse easy to clip against this canonical view volume; clipping planes are axisaligned! projection using the canonical view volume is even easier: just omit the zcoordinate for oblique parallel projection, a shearing transform is part of the composite transform, to “de-oblique” the view volume † Affine transformations preserve parallelism but not lengths and angles. The perspective transformation is a type of non-affine transformation known as a projective transformation, which does not preserve parallelism Adapted from slides for Brown University CS 123, Computer Graphics © 2000 – 2007, A. van Dam. Used with permission. CIS 636/736: (Introduction to) Computer Graphics CG Basics 4 of 8: Viewing Computing & Information Sciences Kansas State University

Viewing Transformation Normalizing Transformation l Problem of taking a picture has now been reduced to problem of finding correct normalizing transformation l It is a bit tricky to find the rotation component of the normalizing transformation. l However, it is easier to find the inverse of this rotational component (trust us) l So we’ll digress for a moment and focus our attention on the inverse of the normalizing transformation, which is called the viewing transformation. l The viewing transformation turns the canonical view into the arbitrary view, or (x, y, z) to (u, v, n) Adapted from slides for Brown University CS 123, Computer Graphics © 2000 – 2007, A. van Dam. Used with permission. CIS 636/736: (Introduction to) Computer Graphics CG Basics 4 of 8: Viewing Computing & Information Sciences Kansas State University

Building Viewing Transformation from View Specification l We know the view specification: Position, Look vector, and Up vector l We need to derive an affine transformation from these parameters that will translate and rotate the canonical view into our arbitrary view the scaling of the film (i. e. the cross-section of the view volume) to make a square cross-section will happen at a later stage, as will clipping l Translation is easy to find: we want to translate the origin to the point Position; therefore, the translation matrix is l Rotation is harder: how do we generate a rotation matrix from the viewing specifications that will turn x, y, z, into u, v, n? a digression on rotation will help answer this Adapted from slides for Brown University CS 123, Computer Graphics © 2000 – 2007, A. van Dam. Used with permission. CIS 636/736: (Introduction to) Computer Graphics CG Basics 4 of 8: Viewing Computing & Information Sciences Kansas State University

Rotation [1] 3 x 3 rotation matrices l We learned about 3 x 3 matrices that “rotate” the world (we’re leaving out the homogeneous coordinate for simplicity) l When they do, the three unit vectors that used to point along the x, y, and z axes are moved to new positions l Because it is a rigid-body rotation the new vectors are still unit vectors the new vectors are still perpendicular to each other the new vectors still satisfy the “right hand rule” l Any matrix transformation that has these three properties is a rotation about some axis by some amount! l Let’s call the three x-axis, y-axis, and z-axis-aligned unit vectors e 1, e 2, e 3 l Writing out: Adapted from slides for Brown University CS 123, Computer Graphics © 2000 – 2007, A. van Dam. Used with permission. CIS 636/736: (Introduction to) Computer Graphics CG Basics 4 of 8: Viewing Computing & Information Sciences Kansas State University

Rotation [2] l Let’s call our rotation matrix M and suppose that it has columns v 1, v 2, and v 3: l When we multiply M by e 1, what do we get? l Similarly for e 2 and e 3: Adapted from slides for Brown University CS 123, Computer Graphics © 2000 – 2007, A. van Dam. Used with permission. CIS 636/736: (Introduction to) Computer Graphics CG Basics 4 of 8: Viewing Computing & Information Sciences Kansas State University

Rotation [3] l Thus, for any matrix M, we know that Me 1 is the first column of M l If M is a rotation matrix, we know that Me 1 (i. e. , where e 1 got rotated to) must be a unit-length vector (because rotations preserve length) l Since Me 1 = v 1, the first column of any rotation matrix M must be a unit vector l Also, the vectors e 1 and e 2 are perpendicular… l So if M is a rotation matrix, the vectors Me 1 and Me 2 are perpendicular… (if you start with perpendicular vectors and rotate them, they’re still perpendicular) l But these are the first and second columns of M … Ditto for the other two pairs l As we noted in the slide on rotation matrices, for a rotation matrix with columns vi columns must be unit vectors: ||vi|| = 1 columns are perpendicular: vi • vj = 0 (i j) Adapted from slides for Brown University CS 123, Computer Graphics © 2000 – 2007, A. van Dam. Used with permission. CIS 636/736: (Introduction to) Computer Graphics CG Basics 4 of 8: Viewing Computing & Information Sciences Kansas State University

Rotation [4] l Therefore (for rotation matrices) l We can write this matrix of vi • vj dot products as where MT is a matrix whose rows are v 1, v 2, and v 3 l Also, for matrices in general, M-1 M = I, (actually, M-1 exists only for “well-behaved” matrices) l Therefore, for rotation matrices only we have just shown that M-1 is simply MT l MT is trivial to compute, M-1 takes considerable work: big win! Adapted from slides for Brown University CS 123, Computer Graphics © 2000 – 2007, A. van Dam. Used with permission. CIS 636/736: (Introduction to) Computer Graphics CG Basics 4 of 8: Viewing Computing & Information Sciences Kansas State University

Rotation [5] Summary l If M is a rotation matrix, then its columns are pairwise perpendicular and have unit length l Inversely, if the columns of a matrix are pairwise perpendicular and have unit length and satisfy the right-hand rule, then the matrix is a rotation l For such a matrix, Adapted from slides for Brown University CS 123, Computer Graphics © 2000 – 2007, A. van Dam. Used with permission. CIS 636/736: (Introduction to) Computer Graphics CG Basics 4 of 8: Viewing Computing & Information Sciences Kansas State University

Summary l History of Projections l Normalizing and Viewing Transformations l Perspective (to Parallel) Transformation l Kinds of Projections Parallel ð Orthographic: top, front, side, other ð Axonometric: isometric, dimetric, trimetric ð Oblique: cavalier, cabinet ð Other Perspective: 1 -point, 2 -point, 3 -point l Viewing in Open. GL CIS 636/736: (Introduction to) Computer Graphics CG Basics 4 of 8: Viewing Computing & Information Sciences Kansas State University

Terminology l World Coordinates l Screen Coordinates l Normalizing Transformation l Viewing Transformation l Duality l Perspective (to Parallel) Transformation l Projections Parallel ð Orthographic: top, front, side, other ð Axonometric: isometric, dimetric, trimetric ð Oblique: cavalier, cabinet ð Other Perspective: 1 -point, 2 -point, 3 -point CIS 636/736: (Introduction to) Computer Graphics CG Basics 4 of 8: Viewing Computing & Information Sciences Kansas State University

Next: Open. GL Tutorial 2 l Four More Short Open. GL Tutorials from SIGGRAPH 2000 l Vicki Shreiner: Animation and Depth Buffering Double buffering Illumination: light positioning, light models, attenuation Material properties Animation basics in Open. GL l Vicki Schreiner: Imaging and Raster Primitives l Ed Angel: Texture Mapping l Dave Shreiner: Advanced Topics Display lists and vertex arrays Accumulation buffer Fog Stencil buffering Fragment programs (to be concluded in Tutorial 3) CIS 636/736: (Introduction to) Computer Graphics CG Basics 4 of 8: Viewing Computing & Information Sciences Kansas State University