Transcription of Affine Transformations
1 University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don FussellAffine TransformationsUniversity of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 2 LogisticsRequired reading:Watt, Section reading:Foley, et al, Chapter F. Rogers and J. Alan Adams, MathematicalElements for Computer Graphics, 2nd Ed., McGraw-Hill, New York, 1990, Chapter :HW #1 handed out MondayProject #1 due on Monday, artifact on of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 3 Geometric transformationsGeometric Transformations will map points in onespace to points in another: (x',y',z') = f(x,y,z).These Transformations can be very simple, such asscaling each coordinate, or complex, such as non-linear twists and 'll focus on Transformations that can berepresented easily with matrix 'll start in of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 4 RepresentationWe can represent a point, p = (x,y), in the planeas a column vectoras a row vector!
2 Xy" # $ % & ' ! xy[]University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 5 Representation, can represent a 2-D transformation M by a matrixIf p is a column vector, M goes on the left:If p is a row vector, MT goes on the right:We will use column vectors.! " p =pMT" x " y []=xy[]acbd# $ % & ' ( ! " p =Mp" x " y # $ % & ' ( =abcd# $ % & ' ( xy# $ % & ' ( ! M=abcd" # $ % & ' University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 6 Two-dimensional transformationsHere's all you get with a 2 x 2 transformationmatrix M:So:We will develop some intimacy with theelements a, b, c, ! " x " y # $ % & ' ( =abcd# $ % & ' ( xy# $ % & ' ( ! " x =ax+by" y =cx+dyUniversity of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 7 IdentitySuppose we choose a=d=1, b=c=0:Gives the identity matrix : Doesn't move the points at all!)))))))
3 1001" # $ % & ' University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 8 ScalingSuppose b=c=0, but let a and d take on any positive value:Gives a scaling matrix :Provides differential (non-uniform) scaling in x and y:! a00d" # $ % & ' ! " x =ax" y =dy! 2002" # $ % & ' ! 12002" # $ % & ' University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 9 ReflectionSuppose b=c=0, but let either a or d go :! "1001# $ % & ' ( ! 100"1# $ % & ' ( University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 10 ShearNow leave a=d=1 and experiment with bThe matrixgives:! 1b01" # $ % & ' ! " x =x+by" y =y! 1101" # $ % & ' University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 11 Effect on unit squareLet's see how a general 2 x 2 transformationM affects the unit square:!))
4 Abcd" # $ % & ' pqrs[]=( p ( q ( r ( s []abcd" # $ % & ' 01100011" # $ % & ' =0aa+bb0cc+dd" # $ % & ' University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 12 Effect on unit square, :Origin invariant under MM can be determined just by knowing how thecorners (1,0) and (0,1) are mappeda and d give x- and y-scalingb and c give x- and y-shearingUniversity of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 13 RotationFrom our observations of the effect on the unit square, itshould be easy to write down a matrix for rotation aboutthe origin :Thus! 10" # $ % & ' (cos())sin())" # $ % & ' 01" # $ % & ' (*sin())cos())" # $ % & ' ! MR=R(")=cos(")#sin(")sin(")cos(")$ % & ' ( ) University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 14 Linear transformationsThe unit square observations also tell us the 2x2 matrix transformationimplies that we are representing a point in a new coordinate system:where u=[a c]T and v=[b d]T are vectors that define a new basis for alinear transformation to this new basis ( , change of basis) is alinear transformation .))
5 ! " p =Mp=abcd# $ % & ' ( xy# $ % & ' ( =uv[]xy# $ % & ' ( =x)u+y)vUniversity of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 15 Limitations of the 2 x 2 matrixA 2 x 2 linear transformation matrix allowsScalingRotationReflectionShearing Q: What important operation does thatleave out?University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 16 Affine transformationsIn order to incorporate the idea that both the basis and theorigin can change, we augment the linear space u, v withan origin that while u and v are basis vectors, the origin t is call u, v, and t (basis and origin) a frame for an , we can represent a change of frame as:This change of frame is also known as an do we write an Affine transformation with matrices?! " p =x#u+y#v+tUniversity of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 17 Homogeneous CoordinatesTo represent Transformations among Affine frames, we can loft theproblem up into 3-space, adding a third component to every point:Note that [a c 0]T and [b d 0]T represent vectors and[tx ty 1]T, [x y 1]T and [x' y' 1]T represent points.)
6 ! " p =Mp=abtxcdty001# $ % % % & ' ( ( ( xy1# $ % % % & ' ( ( ( =uvt[]xy1# $ % % % & ' ( ( ( =x)u+y)v+1)tUniversity of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 18 Homogeneous coordinatesThis allows us to perform translation as well as the lineartransformations as a matrix operation:! " p =MTp" x " y 1# $ % % % & ' ( ( ( =10tx01ty001# $ % % % & ' ( ( ( xy1# $ % % % & ' ( ( ( " x =x+tx" y =y+ty! 1010112001" # $ $ $ % & ' ' ' University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 19 Rotation about arbitrary q to backLine up the matrices for these step in right to left order and : transformation order is important!!Until now, we have only considered rotation about the homogeneous coordinates, you can specify a rotation, Rq,about any point q = [qx qy 1]T with a matrix :University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 20 Points and vectorsFrom now on, we can represent points as have an additional coordinate of w= have an additional coordinate of w=0.)))))))))))))))
7 Thus, a change of origin has noeffect on : What happens if we multiply a matrix by a vector?These representations reflect some of the rules of Affine operations on points andvectors:One useful combination of Affine operations is:Q: What does this describe? ! vector+vector"vector#vector"point$point" point+vector"point+point"! p(t)=p0+tvUniversity of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 21 Barycentric coordinatesA set of points can be used to create an Affine frame. Consider atriangle ABC and a point p:We can form a frame with an origin C and the vectors from C to theother vertices:We can then write P in this coordinate frameThe coordinates ( , , ) are called the barycentric coordinates ofp relative to A, B, and ! ! p="u+#v+t! u=A"Cv=B"Ct=CUniversity of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 22 Computing barycentric coordinatesFor the triangle example we can compute the barycentriccoordinates of P:Cramer s rule gives the solution:Computing the determinant of the denominator gives:!
8 "A+#B+$C=AxBxCxAyByCy111% & ' ' ' ( ) * * * "#$% & ' ' ' ( ) * * * =pxpy1% & ' ' ' ( ) * * * ! BxCy"ByCx+AyCx"AxCy+AxBy"AyBx! "=pxBxCxpyByCy111 AxBxCxAyByCy111#=AxpxCxAypyCy111 AxBxCxAyByCy111$=AxBxpxAyBypy111 AxBxCxAyByCy111 University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 23 Cross productsConsider the cross-product of two vectors, u and v. What isthe geometric interpretation of this cross-product?A cross-product can be computed as:What happens when u and v lie in the x-y plane? What is thearea of the triangle they span?! u"v=ijkuxuyuzvxvyvz=(uyvz#uzvy)i+(uzvx#u xvz)j+(uxvy#uyvx)k=uyvz#uzvyuzvx#uxvzuxv y#uyvx$ % & & & ' ( ) ) ) University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 24 Barycentric coords from area ratiosNow, let s rearrange the equation from two slides ago:The determinant is then just the z-component of(B-A) (C-A), which is two times the area of triangle ABC!
9 Thus, we find:Where SArea(RST) is the signed area of a triangle, which canbe computed with cross-products.! BxCy"ByCx+AyCx"AxCy+AxBy"AyBx=(Bx"Ax)(Cy "Ay)"(By"Ay)(Cx"Ax)! "=SArea(pBC)SArea(ABC)#=SArea(ApC)SArea( ABC)$=SArea(ABp)SArea(ABC)University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 25 Affine and convex combinationsNote that we seem to have added points together, which we said wasillegal, but as long as they have coefficients that sum to one, it s call this an Affine combination. More generallyis a proper Affine combination if:Note that if the i s are all positive, the result is more specifically called aconvex : Why is it called a convex combination?11nii!==" ! p="1p1+K+"npnUniversity of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 26 Basic 3-D Transformations : scalingSome of the 3-D Transformations are just likethe 2-D example, scaling:!
10 " x " y " z 1# $ % % % % & ' ( ( ( ( =sx0000sy0000sz00001# $ % % % % & ' ( ( ( ( xyz1# $ % % % % & ' ( ( ( ( University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 27 Translation in 3D! " x " y " z 1# $ % % % % & ' ( ( ( ( =100tx010ty001tz0001# $ % % % % & ' ( ( ( ( xyz1# $ % % % % & ' ( ( ( ( University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 28 Rotation in 3 DRotation now has more possibilities in 3D:xRyRzRUse right hand rule! Rx(")=10000cos(")#sin(")00sin(")cos(")00 001$ % & & & & ' ( ) ) ) ) Ry(")=cos(")0sin(")00100#sin(")0cos(")00 001$ % & & & & ' ( ) ) ) ) Rz(")=cos(")#sin(")00sin(")cos(")0000100 001$ % & & & & ' ( ) ) ) ) University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 29 Shearing in 3 DShearing is also more complicated.)))))))))))))))