1Modeling TransformationsAdam FinkelsteinPrinceton UniversityCOS 426, Spring 2003Modeling Transformations• Specify transformations for objects o Allows definitions of objects in own coordinate systemso Allows use of object definition multiple times in a sceneH&B Figure 109Overview• 2D Transformationso Basic 2D transformationso Matrix representationo Matrix composition• 3D Transformationso Basic 3D transformationso Same as 2D• Transformation Hierarchieso Scene graphso Ray casting2D Modeling TransformationsScaleRotateTranslateScaleTranslatexyWorld CoordinatesModelingCoordinates2D Modeling TransformationsxyWorld CoordinatesModelingCoordinatesLet’s lookat this indetail…2D Modeling TransformationsxyModelingCoordinates22D Modeling TransformationsxyModelingCoordinatesScale .3, .3Rotate -90Translate 5, 32D Modeling TransformationsxyModelingCoordinatesScale .3, .3Rotate -90Translate 5, 32D Modeling TransformationsxyModelingCoordinatesScale .3, .3Rotate -90Translate 5, 3World CoordinatesBasic 2D Transformations• Translation:o x’ = x + txo y’ = y + ty• Scale:o x’ = x * sx o y’ = y * sy• Shear:o x’ = x + hx*yo y’ = y + hy*x• Rotation:o x’ = x*cosΘ -y*sinΘo y’ = x*sinΘ + y*cosΘTransformations can be combined(with simple algebra)Basic 2D Transformations• Translation:o x’ = x + txo y’ = y + ty• Scale:o x’ = x * sx o y’ = y * sy• Shear:o x’ = x + hx*yo y’ = y + hy*x• Rotation:o x’ = x*cosΘ -y*sinΘo y’ = x*sinΘ + y*cosΘBasic 2D Transformations• Translation:o x’ = x + txo y’ = y + ty• Scale:o x’ = x *sxo y’ = y * sy• Shear:o x’ = x + hx*yo y’ = y + hy*x• Rotation:o x’ = x*cosΘ -y*sinΘo y’ = x*sinΘ + y*cosΘx’ = x*sxy’ = y*syx’ = x*sxy’ = y*sy(x,y)(x’,y’)3Basic 2D Transformations• Translation:o x’ = x + txo y’ = y + ty• Scale:o x’ = x * sx o y’ = y * sy• Shear:o x’ = x + hx*yo y’ = y + hy*x• Rotation:o x’ = x*cosΘ - y*sinΘo 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’)Basic 2D Transformations• Translation:o x’ = x + txo y’ = y + ty• Scale:o x’ = x * sx o y’ = y * sy• Shear:o x’ = x + hx*yo y’ = y + hy*x• Rotation:o x’ = x*cosΘ -y*sinΘo 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’)Basic 2D Transformations• Translation:o x’ = x + txo y’ = y + ty• Scale:o x’ = x * sx o y’ = y * sy• Shear:o x’ = x + hx*yo y’ = y + hy*x• Rotation:o x’ = x*cosΘ -y*sinΘo 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Θ) + tyOverview• 2D Transformationso Basic 2D transformationso Matrix representationo Matrix composition• 3D Transformationso Basic 3D transformationso Same as 2D• Transformation Hierarchieso Scene graphso Ray castingMatrix Representation• Represent 2D transformation by a matrix• Multiply matrix by column vector⇔ apply transformation to point=yxdcbayx''dcbadycxybyaxx+=+=''Matrix Representation• Transformations combined by multiplication=yxlkjihgfedcbayx''Matrices are a convenient and efficient way to represent a sequence of transformations!4=yxdcbayx''2x2 Matrices• What types of transformations can be represented with a 2x2 matrix?2D Identity?yyxx==''=yxyx1001''2D Scale around (0,0)?ysyyxsxx*'*'===yxdcbayx''=yxsysxyx00''2x2 Matrices• What types of transformations can be represented with a 2x2 matrix?2D Rotate around (0,0)?yxyyxx*cos*sin'*sin*cos'Θ+Θ=Θ−Θ==yxdcbayx''ΘΘΘ−Θ=yxyxcossinsincos''2D Shear?yxshyyyshxxx+=+=*'*'=yxdcbayx''=yxshyshxyx11''2x2 Matrices• What types of transformations can be represented with a 2x2 matrix?2D Mirror over Y axis?yyxx=−=''=yxdcbayx''−=yxyx1001''2D Mirror over (0,0)?yyxx−=−=''=yxdcbayx''−−=yxyx1001''=yxdcbayx''2x2 Matrices• What types of transformations can be represented with a 2x2 matrix?2D Translation?tyyytxxx+=+=''Only linear 2D transformations can be represented with a 2x2 matrixNO!Linear Transformations• Linear transformations are combinations of …o Scale,o Rotation,o Shear, ando Mirror• Properties of linear transformations:o Satisfies:o Origin maps to origino Lines map to lineso Parallel lines remain parallelo Ratios are preservedo Closed under composition)()()(22112211pppp TsTsssT +=+=yxdcbayx''2D Translation• 2D translation represented by a 3x3 matrixo Point represented with homogeneous coordinatestyyytxxx+=+=''=110010011''yxtytxyx5Homogeneous Coordinates• Add a 3rd coordinate to every 2D pointo (x, y, w) represents a point at location (x/w, y/w)o (x, y, 0) represents a point at infinityo (0, 0, 0) is not allowed1212(2,1,1)or (4,2,2) or (6,3,3)Convenient coordinate system to represent many useful transformationsxyBasic 2D Transformations• Basic 2D transformations as 3x3 matricesΘΘΘ−Θ=11000cossin0sincos1''yxyx=110010011''yxtytxyx=110001011''yxshyshxyxTranslateRotate
View Full Document