Example: air traffic controller

Orthographic and Perspective Projection - Clemson University

Chapter 10 Orthographic andPerspective Projectionraycastingobject space rendererprojectionscreen space rendererWe have been, until now, creating images by raycasting. By shooting rays fromthe eyepoint out into the scene, we determine what is visible at the screenpixel that the ray passes through. This type of renderer is called an object (orscene) space renderer, since all viewing calculations are done in the world spaceof the scene. This approach is depicted above to the left. We are about tobegin looking atOpenGL, which uses a very different approach. OpenGL usesa screen space rendering approach, as depicted above to the right, which worksby:1. transforming all scene objects from world coordinates to camera coordi-nates by a viewing transform,2. projecting all scene geometry into 2D screen space and then using thisprojection to produce a shaded 10. Orthographic AND Perspective PROJECTION123123 For example, consider the tetrahedron inthe picture to the we were toproject the tetrahedron onto the view plane,it might be that only two of the four trian-gular faces would be visible.

it might be that only two of the four trian-gular faces would be visible. We could color all of the pixels covered by triangle 1 the color of this face, and all those covered by triangle 2 the color of that face, thus mak-ing an image of the tetrahedron from this viewpoint. 10.1 View Transform

Tags:

  Perspective, Train, Projection, Perspective projection

Information

Domain:

Source:

Link to this page:

Please notify us if you found a problem with this document:

Other abuse

Transcription of Orthographic and Perspective Projection - Clemson University

1 Chapter 10 Orthographic andPerspective Projectionraycastingobject space rendererprojectionscreen space rendererWe have been, until now, creating images by raycasting. By shooting rays fromthe eyepoint out into the scene, we determine what is visible at the screenpixel that the ray passes through. This type of renderer is called an object (orscene) space renderer, since all viewing calculations are done in the world spaceof the scene. This approach is depicted above to the left. We are about tobegin looking atOpenGL, which uses a very different approach. OpenGL usesa screen space rendering approach, as depicted above to the right, which worksby:1. transforming all scene objects from world coordinates to camera coordi-nates by a viewing transform,2. projecting all scene geometry into 2D screen space and then using thisprojection to produce a shaded 10. Orthographic AND Perspective PROJECTION123123 For example, consider the tetrahedron inthe picture to the we were toproject the tetrahedron onto the view plane,it might be that only two of the four trian-gular faces would be visible.

2 We could colorall of the pixels covered by triangle 1 thecolor of this face, and all those covered bytriangle 2 the color of that face, thus mak-ing an image of the tetrahedron from View TransformLet us begin by considering how to transform the scene into camera want to view the scene from the camera s point of view. As a convention, incamera space we will let the camera s viewpoint be the originxc= (0,0,0), thecamera s view direction the negative z axisuc= (0,0, 1), and the viewscreen sup direction theyaxis (0,1,0). If the camera does not start out in this positionand orientation in world space, we have to make a change of coordinates. Thisamounts to first translating the entire scene so that the camera is at the origin,then rotating the scene about thexandyaxes so that the view direction vectorucis along the zaxis, and finally rotating the scene about thezaxis so thatcamera is in the desired orientation.

3 This last operation can be facilitated byspecifying a vector that we will callvup, and rotating the scene so thatvuplies inthe upper half of they-zplane. The figure below illustrates this cu zu xu yv upxcucvupu cSummarizing, we do the following operations:1. translatexcto the origin sox c=0,2. rotate aboutxandysou c=u z, and3. rotate aboutzso thatvuplies in the upper half of Projection TRANSFORM65So, the view transformation would be the product of a translationT( xc, yc, zc) takingxc= xcyczc to the origin, and a rotationR, com-bining the three rotations above:Mview= understand how to do the rotations, remember first that we construct thecamera coordinate frame as follows:ux= (uc vup)/ uc vup ,uy=ux rotationx =Rx, we wantu x= 100 ,u y= 010 ,andu z= 001 .The matrix to do this is easy to find, if we remember thatux,uy,uzare mutuallyorthogonal unit vectors. Thus,ux uy=ux uz=uy uz= 0 andux ux=uy uy=uz uz= 1.

4 Thus, if we construct a matrix whose rows are formedfromutx,uty,utzwe will get the result we want:R= utxutyutz ,sinceRux= 100 ,Ruy= 010 ,andRuz= 001 . Projection transformou zu xu cu yu zu xcsu yNow that our model is conveniently in cameracoordinates, it is possible to determine a set ofscreen coordinates. The distance from the view-point to the view screen is known as the thefocallengthof the camera. In a real camera, the fo-cal length is the distance from the lens at which66 CHAPTER 10. Orthographic AND Perspective Projection distant objects come into focus on the camerabackplane. In a pinhole camera, it is simply thedistance to the view screen. If we define the cam-era s focal length to bedn(distance to the nearplane), then the screen centercs= (0,0, dn) and thexandyscreen axes aregiven byu xandu y, assuming that the screen is arranged so its normal isu z( it is perpendicular to the view directionu c).

5 Applying our view transformMviewto the entire scene, everything is in the same coordinate (x1, y1, z1)(x0, y0, z0)(x1, y1)(x0, y0)screenobjectdnx 1(x1, y1, z1)(x0, y0, z0)dnzucxcTo do an Orthographic Projection of the sceneonto the camera plane is now straightforward we just discard thezcoordinate of each vertex,as shown above to the right in a 2D plan do a Perspective Projection , shown below tothe right, we use the device of similar triangles:x1/z=x 1/dny1/z=y 1/dnThus the transform isx = Canonical view volumesThe view volume is the volume swept out by the screen through space in theprojection system being used. For an Orthographic Projection , this is a rect-angular solid, as shown in Figure We use the distancednto denote thedistance of the front face, ornear plane, of the volume anddfto denote anarbitrary, orfar planedepth of the volume. Screen space cameras are generallyset up to ignore (or clip away) any part of the scene not in the view width and height of the volume are determined by camera screen widthwand a Perspective camera, the view volume has a frustum shape, as shown inFigure idea of a canonical view volume is to provide a common frame of refer-ence for processing after the Projection is performed, which decouples shadingand display of an image from the Projection system used.

6 The typical canon-ical view volume is a 2x2x2 cube aligned with the coordinate axes in viewingcoordinates, and centered at the origin. The idea is that no matter what theviewing conditions are, after a Projection transform is performed, all of thescene is transformed into this space, and anything in that scene that is not inthe canonical view volume after that transformation is clipped CANONICAL VIEW VOLUMES67far planenear planedndfucxcwhFigure : Parallel view planenear planedndfucxcwhFigure : Perspective view construct the Projection transform by considering how it will affect the 8corners of the original view volume, under whichever Projection system is Constructing the canonical Orthographic view vol-umeTo construct the canonical view volume under Orthographic Projection , cor-ners (w/2,h/2), ( w/2,h/2), (w/2, h/2), and ( w/2, h/2) should be sentto (1,1), ( 1,1), (1, 1), and ( 1, 1) respectively (herezdoes not matter, aswe are simply scaling in thexandydirections).

7 In the depth (z) direction wewantznto go to 1 andzfto go to 1. We see that this is a scaleS= 2/w00002/h0000 2/(df dn) 00001 ,68 CHAPTER 10. Orthographic AND Perspective Projection followed by a translation in thezdirection to center the cube at the originT= 1 0 000 1 000 0 1 (df+dndf dn)0 0 01 .So the final Orthographic Projection matrix to transform the scene into thecanonical view volume isPortho=TS= 2/w00002/h0000 2df dn (df+dndf dn)0001 Constructing the canonical Perspective view vol-umeh/2-h/2111y = zy = -zzn1 The construction of the canonicalview volume under Perspective pro-jection follows a somewhat differentderivation. First, we scale the per-spective frustum so that its sides arex= z,y= zand its front faceis atz= 1:S= 2/w00002/h0000 1/dn00001 .This is followed by a Perspective transform. Remembering that by similar tri-angles, we showed that the Perspective transform should scale vertexxbydn|z|(note, that the absolute value signs are needed since in camera coordinates, allzvalues in the view volume are negative.)

8 Thus, a Perspective transform shouldproduce the resultx =dn|z|x. The matrix dn0000dn0000 dn000 10 will transformxas follows:Px=P xyz1 = dnxdny dnz z . CANONICAL VIEW VOLUMES69If this result is normalized into homogenous coordinates by scaling by 1/z, wehave dnzx dnzydn1 , which is the desired result. In general, a Perspective transformhas non-zero terms in the fourth row of the matrix and will transform points inthe homogenous coordinates to points in 4-space that are not order to place projected points back into homogeneous coordinates, the per-spective matrix multiplication is followed by a normalization of each transformedpoint by dividing by its ownwcoordinate, to complete the Perspective , to complete the transformation to the canonical view volume, we do aperspective transform combined with a scale and translation inzthat will placeznat 1 andzfat 1:P= dn0000dn0000sztz00 10 ,where the scaleszand the translationtzare yet to be thatPx=P xyz1 = xyszz+tzz =x.

9 After normalizing by thewcoordinate to place the result back in homogeneouscoordinates, we have1zx =x = x/zy/zsz+1ztz1 .The requirements thatzn 1 andzf 1 give us two linear equations(remember that because of the initial scalezn 1 andzf zf/zn):sz+tz= 1,sz+dndftz= these equations simultaneously yieldstz=2dndfdn df,sz=dn+dfdn 10. Orthographic AND Perspective PROJECTIONThus, the final Perspective matrix, transforming from camera space to thecanonical view volume isPpersp=PS= 2dn/w00002dn/h0000dn+dfdn df2dndfdn df00 10


Related search queries