1Modeling TransformationsTom FunkhouserPrinceton UniversityCOS 426, Spring 2006Modeling Transformations• Specify transformations for objects Allows definitions of objects in own coordinate systems Allows use of object definition multiple times in a sceneMike Marr, COS 426Overview• 2D Transformations Basic 2D transformations Matrix representation Matrix composition• 3D Transformations Basic 3D transformations Same as 2D• Transformation Hierarchies Scene graphs 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: 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ΘTransformations can be combined(with simple algebra)Basic 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ΘBasic 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’)3Basic 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’)Basic 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’)Basic 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Θ) + tyOverview• 2D Transformations Basic 2D transformations Matrix representation Matrix composition• 3D Transformations Basic 3D transformations Same as 2D• Transformation Hierarchies Scene graphs 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 … 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''2D Translation• 2D translation represented by a 3x3 matrix Point represented with homogeneous coordinatestyyytxxx+=+='' = 110010011''yxtytxyx5Homogeneous Coordinates• Add a 3rd coordinate to every 2D point (x, y, w) represents a point at location (x/w, y/w) (x, y, 0) represents a point at infinity (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 =
View Full Document