11Modeling TransformationsAdam FinkelsteinPrinceton UniversityC0S 426, Fall 20012Modeling Transformations• Specify transformations for objectsο Allows definitions of objects in own coordinate systemsο Allows use of object definition multiple times in a sceneH&B Figure 1093Overview• 2D Transformationsο Basic 2D transformationsο Matrix representationο Matrix composition• 3D Transformationsο Basic 3D transformationsο Same as 2D• Transformation Hierarchiesο Scene graphsο Ray casting42D Modeling TransformationsScaleRotateTranslateScaleTranslatexyWorld CoordinatesModelingCoordinates52D Modeling TransformationsxyWorld CoordinatesModelingCoordinatesLet’s lookat this indetail…62D Modeling TransformationsxyModelingCoordinates272D Modeling TransformationsxyModelingCoordinatesScale .3, .3Rotate -90Translate 5, 382D Modeling TransformationsxyModelingCoordinatesScale .3, .3Rotate -90Translate 5, 392D Modeling TransformationsxyModelingCoordinatesScale .3, .3Rotate -90Translate 5, 3World Coordinates10Basic 2D Transformations•Translation:ο x’=x+txο y’=y+ty• Scale:ο x’ = x * sxο y’ = y * sy• Shear:ο x’=x+hx*yο y’ = y + hy*x• Rotation:ο x’ = x*cosΘ -y*sinΘο y’ = x*sinΘ +y*cosΘTransformationscan be combined(with simple algebra)11Basic 2D Transformations•Translation:ο x’=x+txο y’=y+ty• Scale:ο x’ = x * sxο y’ = y * sy• Shear:ο x’=x+hx*yο y’ = y + hy*x• Rotation:ο x’ = x*cosΘ -y*sinΘο y’ = x*sinΘ +y*cosΘ12Basic 2D Transformations•Translation:ο x’=x+txο y’=y+ty• Scale:ο x’ = x *sxο y’ = y *sy• Shear:ο x’=x+hx*yο y’ = y + hy*x• Rotation:ο x’ = x*cosΘ -y*sinΘο y’ = x*sinΘ +y*cosΘx’ = x*sxy’ = y*syx’ = x*sxy’ = y*sy(x,y)(x’,y’)313Basic 2D Transformations•Translation:ο x’=x+txο y’=y+ty• Scale:ο x’ = x * sxο y’ = y * sy• Shear:ο x’=x+hx*yο y’ = y + hy*x• Rotation:ο x’ = x*cosΘ - y*sinΘο y’ = x*sinΘ + y*cosΘx’ = (x*sx)*cosΘ−(y*sy)*sinΘy’ = (x*sx)*sinΘ + (y*sy)*cosΘx’ = (x*sx)*cosΘ−(y*sy)*sinΘy’ = (x*sx)*sinΘ + (y*sy)*cosΘ(x’,y’)14Basic 2D Transformations•Translation:ο x’ = x +txο y’ = y +ty• Scale:ο x’ = x * sxο y’ = y * sy• Shear:ο x’=x+hx*yο y’ = y + hy*x• Rotation:ο x’ = x*cosΘ -y*sinΘο y’ = x*sinΘ +y*cosΘx’ = ((x*sx)*cosΘ−(y*sy)*sinΘ)+txy’ = ((x*sx)*sinΘ + (y*sy)*cosΘ)+tyx’ = ((x*sx)*cosΘ−(y*sy)*sinΘ) +txy’ = ((x*sx)*sinΘ + (y*sy)*cosΘ) +ty(x’,y’)15Basic 2D Transformations•Translation:ο x’=x+txο y’=y+ty• Scale:ο x’ = x * sxο y’ = y * sy• Shear:ο x’=x+hx*yο y’ = y + hy*x• Rotation:ο x’ = x*cosΘ -y*sinΘο y’ = x*sinΘ +y*cosΘx’ = ((x*sx)*cosΘ−(y*sy)*sinΘ)+txy’ = ((x*sx)*sinΘ + (y*sy)*cosΘ)+tyx’ = ((x*sx)*cosΘ−(y*sy)*sinΘ)+txy’ = ((x*sx)*sinΘ + (y*sy)*cosΘ)+ty16Overview• 2D Transformationsο Basic 2D transformationsο Matrix representationο Matrix composition• 3D Transformationsο Basic 3D transformationsο Same as 2D• Transformation Hierarchiesο Scene graphsο Ray casting17Matrix Representation• Represent 2D transformation by a matrix• Multiplymatrixbycolumnvector⇔ apply transformation to point=yxdcbayx''dcbadycxybyaxx+=+=''18Matrix Representation• Transformations combined by multiplication=yxlkjihgfedcbayx''Matrices are a convenient and efficient wayto represent a sequence of transformations!419=yxdcbayx''2x2 Matrices• What types of transformations can berepresented with a 2x2 matrix?2D Identity?yyxx==''=yxyx1001''2D Scale around (0,0)?ysyyxsxx*'*'===yxdcbayx''=yxsysxyx00''202x2 Matrices• What types of transformations can berepresented with a 2x2 matrix?2D Rotate around (0,0)?yxyyxx*cos*sin'*sin*cos'Θ+Θ=Θ−Θ==yxdcbayx''ΘΘΘ−Θ=yxyxcossinsincos''2D Shear?yxshyyyshxxx+=+=*'*'=yxdcbayx''=yxshyshxyx11''212x2 Matrices• What types of transformations can berepresented with a 2x2 matrix?2D Mirror over Y axis?yyxx=−=''=yxdcbayx''−=yxyx1001''2DMirrorover(0,0)?yyxx−=−=''=yxdcbayx''−−=yxyx1001''22=yxdcbayx''2x2 Matrices• What types of transformations can berepresented with a 2x2 matrix?2D Translation?tyyytxxx+=+=''Only linear 2D transformationscan be represented with a 2x2 matrixNO!23Linear Transformations• Linear transformations are combinations of …ο Scale,ο Rotation,ο Shear, andο Mirror• Properties of linear transformations:ο Satisfies:ο Origin maps to originο Lines map to linesο Parallel lines remain parallelο Ratios are preservedο Closed under composition)()()(22112211pppp TsTsssT +=+=yxdcbayx''242D Translation• 2D translation represented by a 3x3 matrixο Point represented with homogeneous coordinatestyyytxxx+=+=''=110010011''yxtytxyx525Homogeneous Coordinates• Add a 3rd coordinate to every 2D pointο (x, y, w) represents a point at location (x/w, y/w)ο (x,y,0)representsapointatinfinityο (0,0,0)isnotallowed1212(2,1,1)or (4,2,2) or (6,3,3)Convenient coordinate system torepresent many useful transformationsxy26Basic 2D Transformations• Basic 2D transformations as 3x3 matricesΘΘΘ−Θ=11000cossin0sincos1''yxyx=110010011''yxtytxyx=110001011''yxshyshxyxTranslateRotate
View Full Document