Design Computation COA 8672
Popular in Course
Popular in Architectural Engineering
verified elite notetaker
This 0 page Class Notes was uploaded by Sid Streich on Monday November 2, 2015. The Class Notes belongs to COA 8672 at Georgia Institute of Technology - Main Campus taught by Staff in Fall. Since its upload, it has received 14 views. For similar materials see /class/233851/coa-8672-georgia-institute-of-technology-main-campus in Architectural Engineering at Georgia Institute of Technology - Main Campus.
Reviews for Design Computation
Report this Material
What is Karma?
Karma is the currency of StudySoup.
You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!
Date Created: 11/02/15
JIM BLINN39S CORNER A Trip Down The Graphics Pipeline The Homogeneous Perspective Transform James F Blinn California Institute of Technology Most of the transformations used in computer graphics are pretty boring rotations scales translations and even shears But for pure weirdness you can t top the perspective transfor mation Most people don t have an intuitive feel for what this transform does to a shape so in this month s column I will try to provide one This has practical applications in selecting near and far clipping planes to avoid depth resolution prob lems with many types of rendering algorithms But to under stand perspective we will first have to review some interesting topological properties of the space represented by homogeneous coordinates Homogeneous coordinate representation First let s review how homogeneous coordinates work We represent a 3D point in what I ll call real space X Y Z as a four element vector x y z w in homogeneous space To help distinguish real space from homogeneous space I ll write realspace coordinates in capitals and homogeneousspace co ordinates in lower case The relation between them is X YZX i Z w w w Notice that many different homogeneous space vectors can represent the same realspace point Even though we might have points represented as a fourvector during some of the processing we ultimately will need to convert back to real space by dividing out the w component Transformations con sist of multiplying a point by a 4 X 4 matrix By manipulating various elements in the matrix we can rotate scale shear translate and our favorite perform a perspective projection Moebius space One of the interesting features of homogeneous coordi nates is that they provide a computationally tractable way to represent points that are infinitely far away For example con sider the point 1 0 0 w This represents the real space point lw 0 0 If we make the value of w smaller and smaller then the points X coordinate gets bigger Ultimately if w reaches 0 we have a point with an infinitely large Xcoordinate The ho mogeneous formulation however is simply 1 0 0 0 these values are perfectly ordinary and easy to deal with inside a May 1993 The perspective transform basically turns space inside out Most people don t have an intuitive feel for what this does to a shape so I will try to provide one computer All points with w 0 are at infinity and form what is called the plane at infinity Of course we can t convert these values back to realspace points because we can t divide the coordinates by w but we can still perform geometrical calcula tions with them if we leave them in the form x y z 0 N 0w let s look at what happens if w becomes negative say 01 The real space analog of 1 0 0 w becomes 10 0 0 In other words the point wraps around infinity and comes back in from the negative direction In this scheme therefore it makes sense to say that the point at infinity in the positive di rection 1 0 0 0 is the same as the point at infinity in the negative direction 1 0 0 0 Points at the top of the uni verse wrap around to the bottom points at the right wrap around to the left At first this over ow property might tempt you to say that the space formed by homogeneous coordinates is a toroidal universe like the universe formed by overflow ofinteger coor dinates But the homogeneous universe is different Consider Figure 1 where 1 labeled several infinite points in the X Y plane with their negative counterparts When you tie point A with A B with B C with C and so forth you get a twist in the fabric of space when it connects around infinity The shape formed when you do this with the 2D plane of Figure 1 is B l D Figure 1 Points at infinity 75 called aprojective plane This together with the torus and the Klein bottle is one of the three topological ways to tie 2D space together Several pictures illustrating these shapes ap pear in Steven Barr s really fun book Experiments in Topol 0ng1 and in Rich Riesenfeld s article Homogeneous Coordinates and Projective Planes in Computer Graphicsquot2 It39s important to keep this Moebius twist in mind when try ing to understand the homogeneous perspective transform since that transform does indeed move points through infinity To better understand how this Moebius twist affects homo geneous shapes in real space look at Figure 2 You should see four triangles See them Well the one in the center is obvi ous The other three straddle the plane at infinity and I ve col ored them in three different shades of gray This diagram also illustrates that there are two possible line segments connect ing any two points Look at points A and B One line segment called an internal segment starts at A and moves to the right to point B The other segment starts at B moves to the right wraps around infinity comes in from the left and terminates at A This is called an external segment In the homogeneous universe both these segments are equally valid Finally note how the Moebius twist along the external segment keeps the proper triangle colors connected Coordinate systems There are four coordinate spaces that I m going to discuss here Let me give explicit names to each space and to a canoni cal point in that space 1 3D Real space before the perspective transform X Y Z 2 3DH Homogeneous space before perspective We usually form this by appending a w 1 coordinate to the end of each real space vector so a point is X Y Z 1 Thus ob jects in this space typically lie in the w l hyperplane of 4D space 3DHP Homogeneous space after perspective Here ob jects no longer lie in the w 1 hyperplane and thus have the general coordinates x5 y z w 3DP Real space after perspective This is just the above space with the w coordinate divided out This space is variously called screen space or perspective space A point has the coordinates X5 Y5 Z3 DJ A Whenever I draw a diagram in this article I will label it with 76 Figure 2 Four triangles Three of them straddle the plane at in nity Figure 3 Perspective geometry YZ eyepoint these coordinate system names The most interesting such dia grams directly compare the shape of an object in 3D space to its distortion into 3DP space The main purpose of this article is to provide an intuitive feel for what that distortion is Simple perspective It turns out that the version of the perspective transform that s easiest to understand is not the version typically used in applications Nevertheless to help us understand the trans form I ll start with this simple version and I ll relate it to the more useful form later Let s derive a simple perspective transform from the geome try in Figure 3 where the eye is a distance D in front of the ori gin For an arbitrary point X Y Z in space we want to find its perspective projection onto the X Y plane which we will call X5 Y5 Using similar triangles we get amp Xe DZD and 3 Y DZD so X X quotZD1 and Y Y 39ZD1 This by itself is not a linear transform We can however piggy back the division onto the homogeneous division by defining X X X ZD 1 W and Y amp YquotZD1 w IEEE Computer Graphics amp Applications Figure 4 Postperspective 2 versus preperspective Z Zs We can define ZS symmetrically as 2 5s ZD1w Z5 x5 y z w z X Y Z 20 1 Now we can express this as a homogeneous matrix multiplica tion 1 0 0 0 0 1 0 0 xystswx XYZ10 0 1 VD XYZ1P o 0 0 1 In the homogeneous notation scheme any column vector represents a plane In particular each column of a transforma tion matrix represents a plane The right column of the ma trix 0 0 1D 1 represents the plane Z D This plane contains all the points that the matrix will map to w 0 That is Z D is the plane that gets transformed to the plane at in finity In general you will combine a perspective matrix with other viewing and modeling transformations making the right hand column have four arbitrary values But whatever its contents the right hand column interpreted as a plane will be the plane containing the eyepoint and perpendicular to the line of sight What does it all mean We ve designed the matrix to generate the correct values for X y and Ya But it s the Z values it generates that are inter esting Let39s play around with these values to see what hap pens to 3D shapes subjected to this transform Cherchez la point Let s start by looking at what happens to the Z coordinate It transforms according to the equation May 1993 Willi Y lllll Lewl ll wa S gg eyepoint fiy l D l Ill ZS SDP Figure 5 The picket fence in perspective Z ZS ZD1 A plot of this function appears in Figure 4 Note that when Z is infinite ZS D The transformation of certain key points is particularly illuminating X Y 0 lP X Y 0 1 This means that points in the z 0 plane the plane of the screen don39t move 0 0 D lP 00 D 0 This means that the eyepoint moves to infinity 0 0 D 0P 0 0 D I This means that a point infinitely far forward becomes a local point Picket fence Another way to look at this is to see what happens to a bunch of equally spaced parallel lines perpendicular to the line of sight As shown in Figure 5 they transform to parallel lines of different lengths and unequal spacing Homogeneous space interpretation In homogeneous space the perspective transform is a sim ple shear in the w direction Figure 6 shows this process for the wz slice of homogeneous space Points in 3DH space with w l shear up and down forming 3DHP space Then they project back onto w 1 to give 3DP Note how the eyepoint the Z 0 point and the Z oo point transform W s 230HP Figure 6 The homogeneous view of the perspective transform Now how about X and Y Look at Figure 7 Here I just plotted x z and w the y coordinate operates similarly to x We start with a square seen edge on Perspective multiplica tion shears the square in w Dividing out the w distorts the square into a trapezoid In Figure 8 you see the same thing applied to a cube turn ing it into the frustum of a pyramid Note that this diagram shows the real 3D space transformed to the real 3DP space Region mapping The ultimate understanding of this transformation comes from Figure 9 Figure 9a shows several regions in the YZ slice of 3D space and Figure 9b shows how they get distorted in 3DP space The Y axis at Z 0 doesn t move Region B stretching from the screen to infinity maps to the finite rectan gular region B The point of the viewing pyramid the eye point moves to infinity so the triangular region A transforms to the infinite rectangle A Regions H J E and D bend ap propriately The interesting thing is to look at stuff that started out behind the eye regions C G and F These regions quotwrap around infinityquot and come back in front of the old infi nite plane Notice that reading from the top down regions G C and F map into regions 0 C and F reading bottom up This is because of the Moebius property of homogeneous co ordinates A better matrix When planning a scene you generally specify the View in terms of camera location and viewing direction You then build up a viewing transformation by translating the camera position to the origin and rotating the viewing direction to point down the Z axis Then in order to use the transform we derived here you must translate the eyepoint D units back ward in Z to place the eyepoint at Z D The following more convenient primitive perspective matrix has this move built in 1 0 0 0 1 0 0 O 1 O 0 0 0 1 0 0 0 1 0 O 0 1 0 0 0 0 1 0 0 0 1 10 0 0 1 1D 0 0 D l 0 0 0 1 0 0 D 0 The matrix on the right performs eyeatorigin perspective Note that its rightmost column 0 0 1D 0 is the plane z 0 that will now transform to the plane at infinity It s also convenient to specify the field of view in terms of the anglef0v at the apex of the View pyramid A screen stretching from 1 to 1 viewed from distance D has Dcot 78 Figure 7 The homogeneous view of a square s transform Figure 8 The perspective transform of a cube Ys eyepoint D X XS an The net effect of our new perspective matrix is to map the 3D point X Y Z to the 3DH point E X Y DEDED Z X3 Yr Z3 Note that the effect of a change in the field of view on X and Y is just a simple scaling In other words changing the field of view doesn t change the shape of any objects on the screen it just scales the image uniformly so that more or less of the environment fits within the screen boundaries Depth information Many rendering algorithms use the 2 values that come out of this transformation to do depth comparisons so it s good to have some idea of the range of values this transformation can have Let s see what happens to a few key Z coordinate values under this new transform Z coordinates that start at infinity map to Z D and Z coordinates that start out at 0 map to Z 0 Any points that start out closer to the eye than Z D map to some negative value of Z Depending on how near the eye it is a point can map to a rather enormous negative Z value The eye itself of course maps to minus infinity Objects very close to the eye might generate a divide error if the quo tient of z and m is too big for a floating point number This is a nuisance How can we avoid it Typically we use a clipping plane to remove all objects nearer than a certain distance But close objects that generate divide errors are not the big gest problem The biggest problem is distant objects What happens to the resolution in Z for objects that are far from the eye Let s look at a numerical example Suppose the field of View is about 53 degrees giving a value of D 2 Suppose that two points on a viewed object are at distances Z 500 and Z 501 The perspective transform moves these to the posi tions 500 2 Zy 2 500 j i992 and 501 2 ZS2 501 1 1992016 IEEE Computer Graphics amp Applications Figure 9 Which regions map to where This really starts to push the resolvable limits of single preci sion oatingpoint numbers And using doubleprecision num bers is the cowardly approach We can do everything in single precision if we know the ap proximate range of Z values relative to the eye for objects in our scene We just scale and translate the postperspective ZS values to spread more uniformly over the range 0 to l The easiest way to specify this scale and translation is in terms of two Z values in preperspective 3D space We ll call these 2 for the near value and Z for the far value We then calculate the scale and transformation that maps these values to 0 and 1 respectively in 3DP space A scale and translation in Z will only modify the third column of the matrix so let s solve for the matrix elements that do the desired mapping A point on the near plane maps to 10 0 0 002101 0 00AZBZD quot39OOAlD quot 00 B 0 We want this to map to ZY 0 so we must have B AZ Next a point on the far plane maps to l 0 0 0 0 0 0 00 Zr 1 0 0 A 11 0 0 AZ 0 0 0 Atzf zquot ZrD We want this to map to Z 1 so its z and w components must be equal This gives us Zr A DZf Zn The resultant matrix maps Z to 0 tho l and Z 2 co to Zf Zf Zn In my column Nested Transformations and Blobby Manquot CGampA October 1987 pp 6166 I showed this same matrix but I wrote it a bit differently To get to the form used in that article just multiply the above matrix by the constant factor D sin fav 2 cos fav 2 to get 6 0 O 0 0 C 0 0 O O Q s 0 0 Q on 0 where 5 sin fovZ c cos fav 2 s Q iTzTZ May 1993 Y5 HI Jl Fl Alf VC 7 ZS E39 D39 G39 old plane at infinity 30p There are two practical reasons for this way of specifying the matrix First if the user specifies a field of view of zero de grees the program will not blow up by attempting to calculate an infinite cotangent Admittedly though the matrix will be a bit weird Second if the user wants to use an infinite value for Z a perfectly reasonable thing to do the expression for Q above reduces nicely to Q 5 Now that we have the handles Z and Zto play with let s see how they solve our resolution problem If we use the fairly loose bounds around our object of Z 400 and Zf 600 the perspective matrix gives us 3Z 1200 7 Z You can check that Z 400 maps to Z 0 and Z 600 maps to Z l The Z values of 500 and 501 map respectively into Zx values of 06 and 06048 which are much more readily dis tinguishable The location of 2 and Zare usually associated with near and far clipping planes The problem is that users typically don t want anything clipped off in the near and far directions so they make ZH very small and Zjvery large Making Zjlarge or even infinite doesn t really cause problems but making 2 small does It basically defeats the purpose of our new formu lation cramming the objects in the scene into a depth range very close to Z l The depth resolution available to the ren dering algorithm is then completely lost I have seen a lot of people struggle with this My advice is to place Zn as far away as you can manage In fact for some projects I have had to ani mate the value of Z to track an object as it ies around on the screen Clipping implications In an earlier article A Trip Down the Graphics Pipeline Line Clippingquot CGampA January l99lpp 98105 I wrote about a line clipping algorithm that operated with the per spective transformation we derived here Now that we have a better understanding of homogeneous perspective I want to clear up a few statements made in that article First near and far clipping are optional We must still how ever specify a value for Z and 2 After all some value of Z is going to map to Z 0 and some other value of Z is going to map to Z 1 We can t do anything about that But it s not 79
Are you sure you want to buy this material for
You're already Subscribed!
Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'