Viewing & PerspectiveCSE167: Computer GraphicsInstructor: Steve RotenbergUCSD, Fall 2005Homogeneous Transformations1 0 00 1110001+++=+++=′+++=′+++=′⋅=′′′⋅=′zyxzzzyzxzzyzyyyxyyxzxyxxxxzyxzzzzyyyyxxxxzyxvvvdvcvbvavdvcvbvavdvcvbvavvvvdcbadcbadcbavvvvMv3D TransformationsSo far, we have studied a variety of useful 3D transformations:RotationsTranslationsScalesShearsReflectionsThese are examples of affine transformationsThese can all be combined into a single 4x4 matrix, with [0 0 0 1] on the bottom rowThis implies 12 constants, or 12 degrees of freedom (DOFs)ABCD VectorsWe mentioned that the translation information is easily extracted directly from the matrix, while the rotation/scale/shear/reflection information is encoded into the upper 3x3 portion of the matrixThe 9 constants in the upper 3x3 matrix make up 3 vectors called a, b, and cIf we think of the matrix as a transformation from object space to world space, then the a vector is essentially the object’s x-axis transformed into world space, b is its y-axis in world space, and c is its z-axis in world spaced is of course the position in world space.Example: YawA spaceship is floating out in space, with a matrix W. The pilot wants to turn the ship 10 degrees to the left (yaw). Show how to modify W to achieve this.Example: YawWe simply rotate W around its own b vector, using the ‘arbitrary axis rotation’ matrix:where Ra(a,θ)=−++−−−−−−++−+−−−−+10000)1()1()1(0)1()1()1(0)1()1()1(222222zzxzyyzxxzyyyzyxyzxzyxxxacasacaasacaasacaaacasacaasacaasacaaacaθθθθθθθθθθθθθθθ( ) ( ) ( )WMWdWTbWRdWTM⋅=′−⋅°⋅= .10,..aSpacesSo far, we’ve discussed the following spacesObject space (local space)World space (global space)Camera spaceCamera SpaceLet’s say we want to render an image of a chair from a certain camera’s point of viewThe chair is placed in world space with matrix WThe camera is placed in world space with matrix CThe following transformation takes vertices from the chair’s object space into world space, and then from world space into camera space:Now that we have the object transformed into a space relative to the camera, we can focus on the next step, which is to project this 3D space into a 2D image spacevWCv ⋅⋅=′−1Image SpaceWhat we really need is a mapping from 3D space into a special “2.5D” image spaceFor practical geometric purposes, it should be thought of as a proper 2D space, but each vertex in this space also has a depth (z coordinate), and so mathematically speaking, it really is a 3D space…We will say that the visible portion of the image ranges from -1 to 1 in both x and y, with 0,0 in the center of the imageThe z coordinate will also range from -1 to 1 and will represent the depth (1 being nearest and -1 being farthest)Image space is sometimes called normalized view space or other things…View ProjectionsSo far we know how to transform objects from object space into world space and into camera spaceWhat we need now is some sort of transformation that takes points in 3D camera space and transforms them into our 2.5D image spaceWe will refer to this class of transformations as view projections (or just projections)Simple orthographic view projections can just be treated as one more affine transformation applied after the transformation into camera spaceMore complex perspective projections require a non-affine transformation followed by an additional division to convert from 4D homogeneous space into image spaceIt is also possible to do more elaborate non-linear projections to achieve fish-eye lens effects, etc., but these require significant changes to the rendering process, not only in the vertex transformation stage, and so we will not cover them…Orthographic ProjectionAn orthographic projection is an affine transformation and so it preserves parallel linesAn example of an orthographic projection might be an architect’s top-down view of a house, or a car designer’s side view of a carThese are very valuable for certain applications, but are not used for generating realistic imagesOrthographic Projection( )−+−−+−−−+−−=⋅⋅⋅=′−1000200020002,,,,,1nearfarnearfarnearfarbottomtopbottomtopbottomtopleftrightleftrightleftrightfarneartopbottomrightleftorthoPvWCPvPerspective ProjectionWith a perspective projection, objects become smaller as they get further from the camera, as one normally gets from a photograph or video imageThe goal of most real-world camera lens makers is to achieve a perfect perspective projectionMost realistic computer generated images use perspective projectionsA fundamental property of perspective projections is that parallel lines will not necessarily remain parallel after the transformation (making them non-affine)View VolumeA camera defines some sort of 3D shape in world space that represents the volume viewable by that cameraFor example, a normal perspective camera with a rectangular image describes a sort of infinite pyramid in spaceThe tip point of the pyramid is at the camera’s origin and the pyramid projects outward in front of the camera into spaceIn computer graphics, we typically prevent this pyramid from being infinite by chopping it off at some distance from the camera. We refer to this as the far clipping planeWe also put a limit on the closest range of the pyramid by chopping off the tip. We refer to this as the near clipping planeA pyramid with the tip cut off is known as a frustum. We refer to a standard perspective view volume as a view frustumView FrustumIn a sense, we can think of this view frustrum as a distorted cube, since it has six faces, each with 4 sidesIf we think of this cube as ranging from -1 to 1 in each dimension xyz, we can think of a perspective projection as a mapping from this view frustrum into a normalized view space, or image spaceWe need a way to represent this transformation mathematicallyView FrustumThe view frustum is usually defined by a field of view (FOV) and an aspect ratio, in addition to the near and far clipping plane distancesDepending on the convention, the FOV may represent
View Full Document