0% found this document useful (0 votes)
53 views40 pages

Transformation

Uploaded by

Ankit
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
53 views40 pages

Transformation

Uploaded by

Ankit
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 40
——_ ~« Viewing and Transformation: 2D and 3D Geometric Transformations, 2D and 3D Viewing Transformations, Vanishing points. [3]: Sections 2.1-2.21 (Pages 61-99), Sections 3.1-3.17 (Pages 101-184) 103 Scanned with CamScanner = ————_ CHAPTER TWO TWO-DIMENSIONAL TRANSFORMATIONS 2-1 INTRODUCTION ‘We begin our study of the fundamentals of the mathematics underlying computer graphics by considering the representation and transformation of’ points and lines. Points and the lines which join them, along with an appropriate.drawing algorithm, are used to represent objects or to display-info-mation graphically. The ability to transform ithese points and lines is basic to computer graphics. When visualizing an object, it may be desirable to scale, rotate, translate, distort or develop a perspective view of the object. All of these traasformations can be accomplished using the mathematical techniques discussed in this and the next chapter. 2-2 REPRESENTATION OF POINTS A point is represented in two dimensions by its coordinates. These two values are specified as the elements of a 1-row, 2-column matrix: * [zy] In three dimensions a 1 x 3 matrix [zy 2] is used. Alternately, a point is represented by a 2-row, 1-column matrix [:] Hh. «SB lo4 Shyam Book in'two dimensions or by 61 Scanned with CamScanner 62 MATHEMATICAL ELEMENTS FOR COMPUTER GRAPHICS in three dimensions. Row matrices like [zy] [5] y are frequently called position vectors. In this book a row matrix formulatio the position vectors is used. A series of points, each of which is a position vector relative to some coor- dinate system, is stored in a computer as a matrix or array of numbers. The position of these points is controlled by manipulating the matrix which defines the points. Lines are drawn between the points to generate lines, curves oF pictures. or column matrices like n of 2-3 TRANSFORMATIONS AND MATRICES such as a number store, @ The rules of matrix algebra Appendix B). Many physical Matrix elements can represent various quantities, snetwork or thé coefficients of a set of equations. define allowable operations on these matrices (see problems lead to a matrix formulation. For models of physical systems, the problem is formulated as: given the matrices [A] and [ B] find the solution matrix [1'], ie., [A][ 7] = [ B ]. In this case the solution is [7] = [4 where [.A]~? is the inverse of the square matrix [ A ] (see Re : ‘ nb ‘An altetnate interpretation is to treat the matrix [7 ] as a geometric opera- tor. Here matrix multiplication is used to perform a geometrical transformation” on a set of points represented by the position vectors contained in [A]. The matrices [A] and [7] are assumed known. It is required to determine ‘the ele- ments of the matrix [ B ]. The interpretation of the matrix [7] as a geometrical operator is the foundation of mathematical transformations useful in computer graphics. 2-4 TRANSFORMATION OF POINTS Consider the results of the multiplication of a matrix [z y]} containing the coordinates of a point P and a general 2 x 2 transformation matrix: a \ ixuriate vI[2 b]=ter+a Gezalale vw} @-0 c > c a ° tte ae q tee This mathematical notation means that the initial coordinates x and y are trans- formed toz* and y’, where x* = (az-+cy) and y* = (bx-+dy).t We are interested — — ng eer Tce Appendix B forthe details of matrix multiplication. Scanned with CamScanner ta + — TRANSFORMATION OF POINTS 63 in the implications of considering x* and y’ as the transformed coordinates of the point P. We begin by investigating several special cases. Consider the case where a = d = 1 and c = b = 0. The transformation matrix [Z'] then reduces to the identity matrix” Thus, ea Y ixuri=te vi[p ]-teu-te v1 @-9 and no change in the coordinates of the point P occurs. Since in matrix algebra multiplying by the identity matrix is equivalent to multiplying by 1 in ordinary algebra, this result is expected. Next consider d=1, 6=c=0, ie, 7 Ot . 0 txur=te vi[§ Q]=le which, since z* = az, produces a scale change in the x component of the position vector. The effect of this transformation is shown in Fig. 2-1a. Now consider b=c=0, ie, ? txytriete vI[8 Q]=tee a= te 9) @-4 ‘This yields a scaling of both the z and y coordinates of the original position vector P, as shown in Fig. 2-1b. If a # d, then the scalings are not equal. If a= d> 1, then a pure enlargement or scaling of the coordinates of P occurs. If 0 abem; b:(d — om}) = by ad—be atom i=1,2 (2-24) Scanned with CamScanner TRANSFORMATION OF INTERSECTING LINES 71 ‘The intersection of the transformed lines is obtained in the same mann for the untransformed lines. Thus, er as that (Xp]=[23 of] =f Bib dim} - bymj my—mji” mp—mj Rewriting the components of the intersection point using Eqs. (2-23) and (2-24) yields LG wv] a(bs — ba) + c(bsrm2 — bars) (br ~ ba) +d(bim2—barm) m3z-™M, m2 —™, (2-25) Returning now to the untransformed intersection point +; i ] and applying the same general 2 x 2 transformation we have (a7 Jaleo wI[T] b—bo bimg—bom|[a b mz—my = ™_a— mM, ed = [ (bs — ba) + o(bsm2 — barns). b(bs — be) + d(brmm2 = barns) m2—m, mz—-m, : (2~26) ° Comparing Eqs.-(2-25) and (2-26) shows that they are identical. Consequently, the intersection point transforms into the intersection point. Example 2-2 _Intersecting Lines Consider the two dashed lines AB and EF shown in Fig. 2-3 with end points -1 -1) [B]=[3 5/3) -1/2 3/2) [F]=[3 -2] [A]= and [Z]= ‘The equation of the line AB is ~(3/3)z + y = —(1/3) and of the line EF, z+y= 1. In matrix notation the pair of lines is represented by ts if p]-te ‘Using matrix inversion (see Eqe 2-21) the intersection of these lines is woe fe] SB =[4/5 1/5] 164 shyam Beok Scanned with CamScanner 72. MATHEMATICAS, ELEMENTS FOR COMPUTER Grapnics Nov: cansider the transformation of these lines using, 1 2 (T= i | ‘The resulting lines are shown as A°B" and E* form the equations of the transformed lines are te vip ten with intersection point at [27 yf ]=[1 1]. ‘Transforming the intersection point of the untransformed lines yields (st vil=ler wilt) | = (4/5 vsi[t. 3)-e 1) * Which is identical to the intersection point of the transformed lines. in Fig. 2-3, In matrix Examination of Fig. 2-3 and Ex, 2-2 shows, that the original pair of un- transformed dashed lines AB and EF- are not perpendicular. However, the transformed solid lines A*B* and E*F* are perpendicular. Thus, the transfor- mation [T’ | changed a pair of intersecting nonperpendicular lines into a pair of intersecting perpendicular lines. By implication, [7'];” thie inverse of the transformation, cKanges a pair of intersecting perpendicular lines into a pair of intersecting nonperpendicular lines. This effect can have disastrous geometrical consequences. It is thus of considerable interest to determine under what condi- - tions perpendicular lines transform into perpendicular lines. .We-will return to this question in Sec. 2-14 when a little more background has been presented. ‘Additional examination of Fig. 2-3 and Ex. 2-2 shows that the transforma- tion [77] involved a rotation, a feflection and a staling. Let's consider each of these effects individually. 2-9 - ROTATION Consider the plane triangle ABC shown in Fig. 2-4, The triangle ABC is rotated through 90° about the origin ina counterclockwise sense by the transformation iri=[-1 9] If we use a 3 x 2 matrix containing the + and y coordinates of the triangle’s vertices, then 3-1 13 41 [ 2 al- -1 ‘| 2 ijl? -1 2 Scanned with CamScanner ROTATION 73 -4 Figure 2-4 Rotation. which produces the triangle A*B*C*. A 180° rotation about the origin is ob- tained by using the transformation 1 0 0 = and a 270° rotation about the origin by using ini=[t 9] (7) Of course, the identity matrix in=[9 S| corresponds to a rotation about the origin of either 0° or 360°. Note that neither scaling nor reflection has occurred in these examples. ‘These example transformations produce specific rotations about the origin: 0°, 90°, 180°, 270°. What about rotation about the origin by an arbitrary angle 67 To obtain this result consider the position vector from the origin Jo the point P shown in Fig. 2-5. The length of the vector is rat an angle ¢ to the a-axis. ‘The position vector P is rotated about i origin by the angle @ to P’. o Scanned with CamScanner aS 74. MATHEMATICAL ELEMENTS FOR COMPUTER Gnapincs ny Figure 2-5 — Rotation of a position vector.” Writing’the position vectors for P and P* we have P=[z y]=[rcosd rsing] and : Pe=[z* y*]=[rcos(p+6)" rsin(¢+6)] Using the sum of the angles formulast aliows writing P* as P* =[2*- y*]=[r(cos¢cosé—singsin8) r(cosdsind + sin $cos 8) ] Using the definitions of x and y allows rewriting P* as Pr=[x" y*]=[xcosd—ysind zsind+ycosd] Thus, the transformed point has components z* = xc0s8— ysing (2 ~ 27a) y" =zsin8+ ycosd (2-276) In matrix form [Ce ]=[X][T]=[2* y*] . cos sind ae [325 23] (2-28) —EEE——E teos(¢ + 0) = vospcos 0 = sin gsin 8 Sin($ + 8) = cos¢sind + singcosd Scanned with CamScanner ROTATION 75 Thus; the transformation for a general rotation about the origin by an arbitrary angle 0 is | cos® sind iri=[_ 3 2] (2-29) Rotations are positive counterclockwise about the origin, as shown in Fig. 2-6. Evaluation of the determinant of the general rotation matrix yields det [T'] = cos? +sin?@ =1 (2-30) In general, transformations with a determinant identically equal to +1 yield pure rotations. Suppose now that we wish to rotate the point P* back to P, i.e., perform the inverse transformation. The required rotation angle is obviously —@. From Eq. (2-29) the required transformation matrix is = 9) sin(—8) 9 —sind _ tr [See ech) = fore ee] ea since cos(=8) = cos and sin(—0) = —sind. [7 ]~* is a formal way of writing tthe inverse of” [7]. We can show that [7 "is the inverse of (by recalling that the product of'a matrix and its inverse yields the identity matrix. Here, (rirr=[ 088 =) 0 “sna —sin@ cos@}|sin@ cos@ 7 _ cos? @ + sin? @ —cos6sin @ + cos @ sind ~ | —cos@sin@ + cos@sing cos? 0 + sin? @ 10 =[} Jeu where [ I] is the identity matrix. Examining Eqs. (2-29) and (2-31) reveals another interesting and-useful re- sult. Recall that the transpose of a matrix is obtained interchanging its rows and columns. Forming the transpose of [7'], ie., [7']” and comparing it with [7°]7* shows that cos? sing . ier = [8 eag|eiz (2-32) ‘The inverse of the general rotation matrix [7'] is its transpose. Since for- mally determining the inverse of a matrix is inore computationally expensive than determining its transpose, Eq. (2-32) is an important and useful result, In Senere’, the inverse of any pure rotation matrix, ie., one with a determinant identically equal to +1, is its transpose.t tSuch rices are to be orthogonal, Ly Scanned with CamScanner 76 MATHEMATICAL gieMENtTs FOR COMPUTER GRAPHICS v JY Ta - Lo 4, 2 4 6 8 Figure 2-6 Reflection. 2-10- REFLECTION . ion in the zy plane occurs entirely in the Whereas a pure two-dimensional rotati a reflection is a two-dimensional plane about an axis normal to the: zy plane, 180? rotation out into three space and back into two space about an axis in the;zy plane. Two reflections of the triangle DEF are shown in Fig. 2-6. A reflection about y = 0; the z-axis, is obtained by using iri=[5 al (2-33) In this case the new vertices D*E*F" for the triangle are given by 8 -1 ' =|7 -3 6 -2 4 a (2-34) Scanned with CamScanner REFLECTION 77 A reflection about the line y = occurs for ini=(° A (2-35) ‘The transformed, new vertices D+E*F* are given by [F3]e l-[ 4 Similarly, a reffection about the line y = —z is given by 0-1 = 2 — 36 (T] [ + al ¢ ) Each of these reflection matrices has a determinant that is identically —1. In general, if the determinant of-d transformation matrix is identically “4 then the transformation produces a pure reflection. If two pure reflection transformations about lines passing through the origi’ are applied successively, the result is a pure rotation about the origin. To see this, consider the following example. Example 2-3 Reflection and Rotation Consider the triangle ABC shown in Fig. 2-7, first reflected about the z axis (see Eq: 2-33) and then about the line y = —z (see Eq: 2-36). Specifically, the result of the reflection about the z-axis is oa _ 1 o]_ 4-1 1x j=rxni= [8 al[3 4]-[: =] Reflecting the triangle A*B*C™ about the line y = ones ie a o -1)_[1 74 (Xt) 21x um)=[8 a][.2 ‘(2 =] 3-4 Rotation about the origin by an angle. = 270° (see Eq. 2-29) yields the identical result, i.e., + [X*)=[X][B] = Shyam Beok Scanned with CamScanner 78 MATHEMATICAL ELEMENTS FOR COMPUTER GRAPHICS Figure 2-7 ' Combined reflections yield rotations. Note that. the reflection matrices given above in Eqs. (2-33), and (2-36), are orthogonal; i.e,, the transpose is also the inverse. For example, [2 ales a] a 2-11. SCALING ‘Recalling our discussion of the transformation of points, we see that scaling is _controlled by the magnitude of the two terms on the primary diagonal of the matrix. If the matrix 20 [TI= [ 02 is used as an operator on the vertices of a triangle, a ‘2-times’ enlargement, or uniform scaling, occurs about the origin. If the magnitudes.are unequal, a distor- tion gccurs. These effects are shown in Fig.,2-8. ‘Triangle ABC is transformed by . i: ini=[5 2] Scanned with CamScanner SCALING 79 ol 444 1 en 6 8 Figure 2"8 _ Uniform and nonuniform scaling or distortion. 10 2 “14 where a uniforrn scaling occurs. Transforming triangle ABC 1/2 0 0. 3 to D*E*F" shows distortion due to the nonuniform scale factors. In general, if to yield A°B" by iri=[2 a] e390 with a = d, b= c= 0, a uniform scaling oconss; and if'a # d, b= c — 0 w ronuniform sealing occurs. For a uniform scaling, if'a = d.>°1, a uniform expansion occurs; i.e., the figure gets larger. Ifa = d < 1, then a uniform compression occurs; ie., the figure gets smaller. Nonuniform expansions and compressions occur, depending on whether a dnd d are individually > 1 or a Figure 2-8 also reveals what at first glance is an apparent translation of the transformed triangles. This apparent translation is easily“understood if we recall that the position vectors, not the points, are scaled with respect to the origin. "To see this more clearly examine the transformation of ABC to DEF" more closely. Specifically, 1s Scanned with CamScanner 80 MATHEMATICAL ELEMENTS FOR COMPUTER Gnapincs 42 2 6 : 1/2 0 [x J=(x][T]= |4 All f s|= 2 12 24 1 12 Note that each of the z components of the position vectors of DEF is increased by a scale factor of 3 and the y components of the position vectors by a scale factor of 2. To obtain a pure scaling without apparent translation, the centroid of the figure must be at the origin. This effect is shown in Fig. 2-9, where the triangle ABC with the centroid coordinates (1/3, the base and 1/3 the height) at the origin is scaled by a factor of 2. Specifically, -1 -1 —2 -2 X= = = 20 | a - (X]=1 x17) [3 iG Al [3 | -2-12 COMBINED TRANSFORMATIONS ‘The power of the matrix methods described in the previous sections is clear. By performing matrix operations on the position vectors which define the vertices, the shape and position of the surface can be controlled. However, a desired ori- entation may require more than one transformation. Since matrix multiplication is noncommutative, the order of application of the transformations is important. Figure 2-9 Uniform scaling -vithout apparent translation. be . Scanned with CamScanner ComBINED TRANSFORMATIONS 8] In order to illustrate the effect of noncommu consider the operations of rotation and reflection o: If a 90° rotation, [ 7; ], is followed by reflection ¢ these two consecutive transformations give tative matrix multiplication, ~ n the position vector [zy], hough the line y=—=, (73) el=(xin=te a[_9 and then (M1=1x Ut )=t-v 2i[ 2B] at-e a) On the other hand, if reflection is followed by rotation, the results’ given by x1=(41mI1=12 v[_$ “h]=t-v -2) . ol at edepeyniet-v -2)[ 2 b]=te 0 are obtained. The results are different, confirming that the order of application of matrix transformations is important. . Another important point is illustrated by the above results and by the exam- ple given below. Above, the individual transformation matrices were successively applied to the successively obtained position vectors, e.g., [z v[M]>[2 y') and (2 vm bt wv) In the example below the individual transformations are first combined or. con- catenated and then the concatenated transformation is applied to the original position vector, e.g- (1 ][Z2] [7s] and[z y][Ts]>[2* y*). Example 2-4 Combined Two-Dimensional Transformations Consider the triangle ABC shown in Fig. 2-10. The two transformations are a +90° rotation about the origin: 0.1 imi=[2 a] 7 Shyam Beok and a-reflection through the line y = Scanned with CamScanner 82 MATHEMATICAL ELEMENTS FOR COMPUTER GRapnics xx Figure 2-10 Combined two-dimensional transformations. ‘The effect of the combined transformation [73] = [Ti ][Z2] on. the tale ABC is (X*]=[XUHMBI=(XUB) sale -HIR : ‘The final zesult'is shown as A°B°C” and the intermediate result as A'B'C’ in Fig. 2-10. Reversing the order of application of the transformations yields (X*]=[X][% [MB] =(XNT] GJ alae 3-8 3] 44 or ‘The final result is shown as D*E' Fig. 2-10. and the intermediate result as D'E’F’ in Scanned with CamScanner ‘TRANSFORMATION OF THE UNIT SQUARE. 83 ‘The results are different, again confirming: that the order of applicatior. of the transformations is important, Note also that det[7] = =i and det [Ts] = -1, indicating that both results can be obtained by a single re- fiection. A"B°C*,can be obtained from ABC by reflection through the y-axis (see Its] ‘and Eq. 2-34). D*E*F* can be obtained from ABC by reflection through the x-axis (see [Ta ] and Eq. 2-33), 2-13 TRANSFORMAYION: oF THE UNIT SQUARE So far we have'‘conéeiitrated on the behavior of points and lines to determine thé effect” of ‘sittiplé ‘miatiix ‘transformations. However, the matrix is ctrectly * cOrisidéréd’to operaté'on every point if’ the plane: As-has been shown, the only point ‘that ‘rémains invariarit under-a:2 x 2'matrix- transformation is the origin. All other'points ‘within the plane are transformed. This transformation may be interpretéd as'a stretching of the original plane and’ coordiniate systern into a new shape! More'formally, we say that-the transformation causes'a'snapping from one coordinate space into a second. “Coliside? ai Squsre'grid network consisting of unit squares ia the dy plane as shoiiii ii Fig. 2-11. “The four position vectors of a unit square with one corner at the origin of thé coordinate system are rigin of the:coordinates At Ai(ad — be) ~~ " (@-41) This is @ useful technique for determining the areas of arbitrary shapes. Scanned with CamScanner TRANSFORMATION OF THE UNIT SQUARE 985 Example 2-5 Area Scaling ‘The trisiigle ABC with position vectoré:(1 0], [0 1] and (-1 0}; i8 transformed by m-[2 3] to create a second triangle A*B"C* as shown in Fig. 2-12. ‘The area of the triangle ABC is A= F(ase)(height) = #0) =1 Using Ea. (2-41) the area of the transformed triangle A”. Ag=:Ai(ad ~be) = (6 + 2) ‘Now the-vertices of the trarisformed'triangle A°B* [2 )isal-[2 3 Calculating the area from the transformed vertices yields ae J (base) (height) = pow =8 . which confirms the previous result. Figure 2-12 Area scaling. * . S B shyam Beok Scanned with CamScanner 86 stAtiniieariCaL eLeMENTs F6n COMPUTER GRAPHICS 2-14 “SOLID BODY TRANSFORMATIONS We now return to the question posed in Sec..2-8, i.e., when; do; perpendicular lines transform as perpendicular lines? First conside: question of when is the angle between intersecting Recall that the dot or scalar. product of two the somewhat more general lines preserved? vectors is a os - 7 Va-Va = VieVas + ViyVay =|Vil |Valcos0 (2-42) and the cross product of two vectors:confined tg. the two-dimensional zy plane wt. ob _ VaxVe = (VisVay — VasViy)k = [WallValesing (2-43) where the subscripts z, y refer.to the z and y components of the vector, @ is the acute angle between the vect, iors and & is the unit vector Perpendicular to the zy * plane. : ‘Transforming Vj; and V2 using a general 2.x'2 transformation yields Y =|[Ys Vy]fao [Wi}iri~ [Hs Vay | Le a is a[MstVy Ws+dViy] _ [Ve 2 ' : = [setae we hav [¥] | The cross product of Vit and V7 is VixVg = (ad ~ 0b)(Vis Vay — VaaViy) = Weil |Ve [sing (2-45) Similarly the scalar product is Ve V, = (a? +B? Wis Vaz + (C7 + d?WiyVay + (ac-+ bd)(VisVoy + ViyVoz) =IVy 11% | cos@ . (2—48) Requiring that the magnitude of the vectors, as well’as the remains unchanged, comparing Eqs. (2-42) and: (2°46 45) and equating coefficients of like terms yields’. ,. angle between them, ) and Eqs. (2-43) and (2— +R a1 (2-470) e+d=1 * (2-470) act bd=0 -(2 = 47) ad—be = +1 (2-48) Equations (2-47a, ie, 5,¢) cortespond to the conditions that a matrix be orthogonal, (THUTT = (27 F =[ 7] Scanned with CamScanner TRANSLATIONS AND HOMOGENEOUS COORDINATES 87 a b) fa ec] [ore ac+bd]_ [1 * [‘¢ 4] b d|Tlactbd o+d o1 ‘Equation (2-48) requires that the determinant of: the transformation matrix be +1. - ‘Thus, the angles between intersecting e Since reflective transformations aré also ‘orthogonal wi these results are easily extended. : preserved, but the,angle between. the, transformed vectors is.techn - Hence, the angle is technically not preserved. Still, perpendicular Jines transform as perpendicular lines. Since sin(2x—) = — sin @, ad—be = —1. ‘Pure rotations and reflections are called rigid Body: transformations. In addition, a few minutes’ thought or experimentation reveals that uniform scalings-also preserve the angle seamen intersecting lines but not the magnitudes of the transformed vectors. lines are preseryed by pure rotation. ith a determinant of -1, 2 he vectors is 2-15, ‘TRANSLATIONS AND. HOMOGENEOUS COORDINATES ‘4 number of transformations governed by-the general 2.x 2 transformation ma- itix, e.g., rotation, reflection; scaling, shearing etc., were discussed in the previ- ous sections. As noted previously, the origin of the ‘coordinate system is invariant ortlvaenpect to all of these transformations. However, it is mecessary to be able to-modify the ‘position of the-origin, i.c., to transform every point'in the two- ‘Tmersional plane. ‘This can be accomplished-by translating the origin or any other point in the two-dimensional plane, i.e., az+cy+m yi sbrtdytn Unfortunately, it is not possible to introduce the constants of translation m, 7” into the general,2 x 2 transformation matrix; theré i8 no room! - ‘This difficulty can be overcome by introducitig homogeneous coordinates. ‘The homogeneous coordinates of a nonomogeneous position vector [z y] are [2’ yh) wheie'e =a!/h and y = y'/h and h is any redl number. Note that h = 0 has special meaning. .One set of homogeneous coordifates is always of the form{z y 1]. We choose this form to represent the position vector [zy] ierthe physical zy plane. All other homogeneous coordinates are of the form [hc hy hi]. There is no unique homogeneous coordinate representation, €.g., {6 4 2],[12 8 4],[3 2 1] all represent the physical point (3, 2). _ The general transformation matrix is now 3 x 3. Specifically, abo ini=[ a ‘| (2-49) mnti tSince an or F a3 8 orthogonal matrix preserves boththe angle between the vectors and thelr magni: m sealing transformation matrix is not orthogonal. Scanned with CamScanner 88 MATHEMATICAL ELEMENTS FOR COMPUTER GRaPuics whiere the’elements a,b, c,d of the upper left 2 x 2 submatrix have exactly the same effects revealed by our previous discussions. m,n are the translation factors in the z and y directions, respectively. The pure two-dimensional translation inatrix is . 1 0.0 [zt yt 1jJ=[z y 1] f 0 1:0) =[c2+m ytn 1) (2-50) mnt . Notice that now évery‘poiit in the two-dimensiorial ilaine, even the origin (x= y = 0), can bé transformed. ‘ 2-16 ROTATION ABOUT AN ARBITRARY POINT Previously we have considered rotations as occurring about the origin. Homoge- neous coordinates provide a mechanism for accomplishing rotations about points other than ‘the otigin. In general, a rotation about‘an arbitrary point can be ac- complished by first translating the point to the origin, performing the required rotation, and then translating the result back’to*the original center of rotation. ‘Thus, rotation of the position vector [¢ jy, -1] about the’ point m,n through an arbitrary angle can be accomplished by’ + a 00 cos? sind: 0 z+ 0 ziy 1) 0 10 —sin@ cos@ 0 ee Se =. > o -o 2 mn iy (2-51) By carrying out the two interior matrix products we can write ’ cos 0 sind 0 let oy sind, _ 6088 0 : —m(cos@—1)), . { -n(cos 9 = 1) * : e Tr tnsino@ J —msind. : (2=52) An example illustrates this result. Example 2-6 Rotation About an. Arbitrary-Point. Suppose the center of an object is at [4 3] and it is desired to rotate the object 90° counterclockwise about its center. Using the matrix 010 -1 00 001 Scanned with CamScanner | REFLECTION THROUGH AN ARBITRARY.LINE 89 wut the origin, not the object center. The necessai slate.the object so that the desired center of. rotation is the translation matrix 1 00 0 10 4-31 ‘and finally translate the results of the rotation ‘means of the inverse translation matrix. The causes’a rotation abot cedure is. tovfirst tran: at the origin by using Next apply the rotation matrix, back to. the original. center by entire, operation ae ofp ee 010771 00 fet aJ=lz-y 2] 9 2 of] -2 0 0 o 1°70 " v4 -3 1f| 0 0 1) L4-3 2 can be combined into one matrix operation by concatenating the transformar tion matrices, i.e., 0 10 {2 yt Tale y Wf-2 oo # -1. i ‘ 2-17 REFLECTION THROUGH AN ARBITRARY LINE Previously (see Sec. 2-10) reflection through lines that passed through the origin was discussed. Occasionally reflection of an object through a line that does not. pass through tlie origin is required. This can be accomplished using @ procedure Pmilar to that for rotation about an arbitrary point Specifically, ‘Translate the ling and the object s Rotate the’ line and the object about with one of the coordinate axes. |! Reflect through the coordinate axis. ‘Apply the inverse rotation about the origin. ‘Translate back to the original location. 0 that the line passes through the origi the origin until the line is coincident ie resulting concatenated matrix is (T]= (rRNA WR r In-matrix notation t (2-53), where ‘ 7" js the translation matrix Ris the rotation matrix about the origin Rl is the reflection matrix ‘The translations, rotations and reflections are also appli transformed. An example is given below. ‘ed to the igure to be Scanned with CamScanner 90 MATHEMATICAL ELEMENTS FOU 000 AB HICS ‘Example 2-7 Reflection Through:an Arbitrary Line Condider the line L and the triangle ABC'shown in Fig. 2-130: "The equation of the line L is y ders) ‘The positioncvectors[2 4 1],[4 6 1] and[2 6 1] describe the ver- tices ofthe triangle ABC. ~ ‘The line L will pass through the origin by translating it-=2 units in the v direction. The resulting line can be made coincident with'the z-axis by rotating it by —tan?(1) = —26.57° about the origin. Equation (2-33) is then used to reflect the triangle through the z-axis. The transformed position vectors of, the triangle are then rotated and translated back to the original orientation. The combined transformation is 1 (0 0} fav -1/vE 0] f1* 0 0 ni=[2 1 | v5 2/v5 0 [2 1 °] EL 0-21 0 o 1f1o ‘0 1 ve ve ‘| [: 0 ‘| -1/¥5, 2/¥5.0||0 1.0 oO 0 1 o21 3/5 4/5 :0 {T] 4/5: -3/5 0 [8/5 16/5 1 _lsind the transformed position vectors for the triangle A‘B°C" are 1 3/5 4/8 ‘| [zs 12/5 ] i| 4/5 -3/5 0] =| 28/5 14/5, 1 1J | -8/5 16/5 1 22/5'° 6/8 1 as shows in Fig. 2-13a. Figures 2-13b through 2-13e show-the various steps. in the transformation. : me 2-18 PROJECTION - A GEOMETRIC INTERPRETATION OF HOMOGENEOUS COORDINATES 2 . The general 3 x 3 transformation matrix for.two-dimensional homogeneous co- ordinates can be subdivided into four parts: ab io op [T]=,e¢ 4 fog mon 3 Scanned with CamScanner ETRIC INTERPRETATION OF HOMOGENEOUS COORDINATES | 91. fae es, GEOM! ay nyt @ ‘Translation @) ea Auge ation fe) Pigure 2-13 Reflection through an arbitrary line. (a) Original and find! position; (b) aaacinte Line through origin; (c) rotate lin to z-axis; (d)Feflect about z-axis; (e) undo rotation; (a) undo translation, Scanned with CamScanner 92 MATHEMATICAL ELEMENTS FOR COMPUTER Gnapaics Recall that a,b,¢ and d produce scaling, rotation, reflection and shearing; and ‘™m and n produce translation. In the previous two sections p = q 0 and s = 1. Suppose p and q are not zero. What are the effects? ‘A ‘geoinetric ihterpretation is useful. . When p =-g = 0 and s = 1, the homogeneous coordinate of thie transformed Position vectors is always h = 1. Geometrically this result is interpreted as confining the transformation to the h = 1 physical:plane. ‘To'show the effect of p # 0, q # 0 in the third column in the general 3 x 3 transformation matrix, consider the following: 10 p [X ¥ h]=[he hy h]=[z y 1]]/0 1 ¢ : oo 1 =[c y (prt+qy+1)] (2-55) Here X = hz, Y = hy and h = pr + qy+1. The transformed position vector expressed in homogeneous coordinates now lies in a plane in three-dimensional space defined by h = pz + qy +1. This transformation is shown in Fig. 2-14, where the line-AB in the physical (h = 1) plane is transformed to the line CD in the h #1 plane, ie., pX +q¥ —h+1=0. Figure 2-14 Transformation from the physical (h =.1) plane into the h # 1 plane and projection from the h # 1 plane back into the physical plane. Scanned with CamScanner GEOMETRIC INTERPRETATION OF HOMOGENEOUS COORDINATES 9: 3 However, the results of interest are those in the physical 5 ‘al plane c i to h= 1, These results can be obtained by geometrically projecting CD tne the h #1 plane back onto the h = 1 plane using a pencil of raya through the origin. From Fig. 2-14, using similar triangles, : ¥ a ¥ ck or in homogeneous coordinates ee tev y=[% Ff] Now, normalizing Eq. (2-55) by dividing through by the homogeneous co- ordinate value h yields ye GY, = y 1j=|=—> = = | SO > 1 - tie w=[F 5 2] Fert ores ] (2. te) or © z a (2 — 57a) ho pe+qytl ¢ ) a _ (2-878) ho petqyel The details are given in the example below. Example 2-8 Projection in Homogeneous Coordinates For the line AB in Fig. 2-14 we have, with p=g=1,[A]=[1 3 1}and [B)=[4 1 1h [S]- [4] [2 3 4) [2 7 i|-[: 3 3] D B a Nig, a 416 Thus, (C]=[1 3 5]and[D]=[4 1 6] in the plane h=a+y+1. Projecting back onto the h = 1 physical plane by dividing through by the homogeneous coordinate factor yields the two-dimensional transformed points {orJ=f1 3 5)=[1/5 3/5 1] [D*}=[4 1 6)=[2/3 1/6 1) ‘The result is shown in Fig. 2-14. “) ‘Shyam Beok Scanned with CamScanner 94 MATHEMATICAL ELEMENTS FOR COMS\TER GRAPHICS 2-19. OVERALL SCALING The remaining unexplained element in the general 3 x 3 transformation matrix (see Eq. 2-54), s, produces overal? scaling; i.c., all components of the position vector are equally scaled. To show this, consider the transformation 100 [X Y h]=[z y 1J]]0 1 0] =[2 y 3} (2-58) 00s Here, X =z, ¥Y =y and h =<. After normalizing, this yields x*=2 and yal . 3 3 ‘Thus, the transformation is[z y 1][T]=[% 4% 1], a uniform scaling of the position vector. If s < 1, then an expansion otcurs; and if s > 1, a compression occurs. Note that this is also a transformation out of the A = 1 plane. Here, h = $= constant. Hence, the h # 1 plane is parallel to the h = 1 plane. A geometric interpretation of this effect is shown in Fig. 2-15. If s < 1, then the h = constant plane lies between the h = 1 and h = 0 planes. Consequently, when the transformed line AB is projected back onto the h = 1 plane to A*B} it becomes larger. Similarly, if s > 1, then the h = constant plane lies beyond the h = 1 plane along the h-axis. When the transformed line CD is projected back onto the h = 1 plane to C*D} it becomes smaller. n=2 Figure 2-15 A:geometric interpretation of overall scaling. Scanned with CamScanner POINTS AT INFINITY 95 2-20 POINTS AT INFINITY Homogeneous coordinates provide a convenient and efficient technique for map- ping a set of points from one coordinate system into a corresponding set in an alternate coordinate system. Frequently, an infinite range in one coordinate sys- tem is mapped into a finite range in an alternate coordinate system. Unless the mappings are carefully chosen, parallel lines may not map into parallel lines. However, intersection points map into intersection points. This property is used to determine the homogeneous coordinate representation of a point at infinity. ‘We begin by considering the pair of intersecting lines given by aty 2 — 3y which have an intersection point at x = 3/5, y.= 2/5. Writing the equations as x+y—1=0 and 2c — 3y = 0 and casting them in matrix form yields 1 2 {zy 1}{ 1-3] =[0 0] -1 0 [X][a']=[R) or If [ M’] ‘were square, the intersection could be obtained by matrix inversion. This can be accomplished by slightly rewriting the system of original equations. Specifically, zty-1= 2 — By 1=1 In matrix form this is [X][41]=[R] ie, 3 1 200 [z y 1]] 1 -3 0} =[0 0 1) -1 01 ‘The inverse of this square matrix ist 3/5 2/5 0) 1 [3 20 [My =]1/5 -1/5 0 =3]1 -1 0 3/5 2/5 1 3025 inversion techniques are discussed in Ref. 2-1 or any good linear algebra book. Scanned with CamScanner 96 MATHEMATICAL ELEMENTS FOR COMPUTER GRapiics Miiltiplying both sides of the equation by [M ]~* and noting that [mMj(mMy? = [J], the identity matrix, yields . 7 3 20 [zy 1]= 510 0 1}]1 -1 0} =[3/5 2/5 1) 3 25 : Thus, the intersection point is again z = 3/5 and y = 2/5. Now consider two parallel lines defined by zty=1 z+y=0 ; i By definition, in Euclidean (common) geometric space, the intersection point of . this ‘pair of parallel lines occurs at infinity. Proceeding, as above, to calculate the intersection point of these lines leads to the matrix formulation 10 fz 9 1)| 1 1 O|=[0 © 1) -101 : However, even though the matrix is square it does not have an inverse, since two rows are identical. The matrix is said to be singular. Another alternate formulation is possible which does have an invertible matrix. This is obtained by. rewriting the system of equations as zy zt+y=0 zea In matrix form this is i 2 1 [xz y 1}] 11 0}/=[0 0 « -10 0, Here, the matrix is not singular; the inverse exists and is 0 0-1 (wy?t=jo 1 1 1-1 o Multiplying both sides of the equation by the inverse yields 0 1-1 [xz y 1J=[0 0 aft 1 ‘] 1-1 06 z[1 -1 0] Scanned with CamScanner Te POINTS AT INFINITY 97 ‘The resulting homogencous coordinates [1 —1 0) represent the ‘poi : tersection’ for the two parallel lines, i. a point at infinity. Specifically ito sents the point at infinity in the direction [1 —1]in the two-dimensional ee, In general, the two-dimensional homogeneo : us vector [a 0} represents ti point at infinity on the line ay — bx = 0. Some examples are: ie e [1 0 0] on the positive z-axis [-1 0 0] onthe negative z-axis [0 1 0] onthe positive y-axis [0 -1 0] onthe negative y-axis [1 1 0] along the line y= in the direction [1 1] The fact that a vector with the homogeneous component h = 0 does indeed Tepresent a point at infinity can also be illustrated by the limiting process shown in Table 2-1. Consider the line y* = (3/4)z* and the point [X Y h] = [4 3 1]. Recalling that a unique representation of a position vector does not exist in homogeneous coordinates, the point [4 3 1] is represented in homogeneous coordinates in all the ways shown in Table 2-1. Note that in Table 2-1 as h — 0, the ratio of y*/z* remains at 3/4, as is required by the governing equation. Further, note that successive pairs of (x3y") all of which fall on the line y* = (3/4)z*, become closer to infinity. Thus, in the limit as h — 0, the point at infinity is given by[X Y h]=[4 3 0] in homogeneous coordinates. By recalling Fig. 2-15, a geometrical interpretation of the limiting. process as » 4 (is also easily illustrated. Consider a line of unit length from z = 0, y = 0 in the direction [1 0], in the plane h = s (s <1). As s — 0 the projection of this line back onto the h = 1 physical plane by a pencil of rays through the origin becomes of infinite length. Consequently, the end point of the line must represent the point at infinity on the z-axis: : 7 ‘Table 2-1 Homogeneous Coordinates for the Point [4 3] h = vx ¥ & 4 3 4 3 728 6 4 8 (eo WO 1/100 400 300 4 3 shyam pool. Scanned with CamScanner 98 MATHEMATICAL ELEMENTS FOR COMPUTER GRapuics ‘2-21 ‘TRANSFORMATION CONVENTIONS Various conventions are used to represent data and to perform transfortiations with matrix multiplication. Extreme care is necessary in defining the problem and interpreting the results. For example, before performing a rotation the following decisions must be made: ‘Are the position vectors (vertices) to be rotated defined relative to a right- hand coordinate or a left-hand coordinate system? Is the object or the coordinate system being rotated? How are positive and negative rotations defined? Are the position vectors stored as a row matrix or as a column matrix? About what line, or axis, is rotation to occur? In this text a right-hand coordinate system is used, the object is rotated in a fixed coordinate system, positive rotation is defined using the right-hand rule, iie., clockwise about’an axis as seen by an observer at the origin looking outward along the positive axis, and position vectors are represented as row matrices. ; Equation (2-29) gives the transformation for positive rotation about the origin or about the z-axis. Since position vectors are represented as row matri- ces, the transformation matrix appears after the data or position vector matrix. This is a post-multiplication transformation. Using homogeneous coordinates for positive rotation-by an angle @ of an object about the origin (z-axis) using a post-multiplication transformation gives [xX] =[X][R] cos@ sind 0 [et yt 1J=[z y 1]]-sind cos? 0 (2-59) 0 2 If we choose to represent the position vectors in homogeneous coordinates as a column matrix, then the same rotation is performed using Ex ]=[RY 14] zs cos@, -sind 0] [z ye |= | sind cosd 0] Jy (2-60) 1 0 o ast Equation (2-60) is called a premultiplication transformation because the transformation matrix appears before the column position vector or data matri: Notice that the 3x3 matrix in Eq. (2-60) is also the transpose of the 3x3 matrix in Eq, (2-59). That is, the rows and columns have been interchanged. Scanned with CamScanner TRANSFORMATION CONVENTIONS 99 ‘To rotate the coordinate system and keep the position vectors fixed, simply replace 0 with —@ in Eq, (2-59), Recall that sind = ~sin(—8) and cos® = cos(—@). Equation (2-59) is then cos# —sind 0 [2 y 1J=[z y 1]]} sind cosd 0 (2-61) 0 ou Notice that the 3 x 3 matrix is again the inverse and also the transpose of that in Eq, (2-59). If the coordinate system is rotated and a left-hand coordinate system used, then the replacement of 8 with -0 is made twice and Eq. (2-59) is again valid, assuming a post-multiplication transformation is used on a row data matrix. Note that, as shown in Fig. 2-16, a counterclockwise rotation of the vertices which represent an object is identical to a clockwise rotation of the coordinate axes for a fixed object. Again, no change occurs in the 3 x 3 transformation Scanned with CamScanner

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy