Modeling Transformation
Overview 2D Transformation 3D Transformation Basic 2D transformations Matrix representation Matrix Composition 3D Transformation Basic 3D transformations Same as 2D Transformation Hierarchies Scene graphs Ray casting
Modeling Transformation Specify transformations for objects Allow definitions of objects in own coordinate systems Allow use of object definition multiple times in a scene Ref] Hearn & Baker
2D Modeling Transformations
2D Modeling Transformations
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 * cosq - y * sinq y’ = x * sinq + y * cosq
Matrix Representation Represent 2D transformation by a matrix Multiply matrix by column vector Apply transformation to point
Matrix Representation Transformations combined by multiplication Matrices are a convenient and efficient way to represent a sequence of transformations
2 x 2 Matrices What types of transformations can be represented with a 2 x 2 matrix? 2D Identity 2D Scale around (0, 0)
2 x 2 Matrices What types of transformations can be represented with a 2x 2 matrix? 2D Rotate around (0, 0) 2D Shear shx = 2
2 x 2 Matrices What types of transformations can be represented with a 2x 2 matrix? 2D Mirror (=Reflection) over Y axis 2D Mirror over (0, 0)
Only linear 2D transformation can be presented with a 2 x 2 matrix 2 x 2 Matrices What types of transformations can be represented with a 2x 2 matrix? 2D Translation ? NO! Only linear 2D transformation can be presented with a 2 x 2 matrix
Linear Transformations Linear transformations are combinations of … Scale Rotation Shear Mirror (=Reflection) Properties of linear transformations Satisfies: Origin maps to origin Lines map to lines Parallel line remain parallel Ratios are preserved Closed under composition
2D Translation 2D Translation represented by a 3 x 3 matrix Point represented with homogeneous coordinate
Homogeneous 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 allowed
Basic 2D Transformations Basic 2D Transformations as 3 x 3 matrices
Affine Transformations Affine Transformations are combinations of … Linear transformation Translation Properties of affine transformations Origin does not necessarily map to origin Lines map to lines Parallel line remain parallel Ratios are preserved Closed under composition
Transformation : Rigid-Body / Euclidean Transforms Rigid Body Transformation (=rigid motion) A transform made up of only translation and rotation Preserve the shape of the objects that they act on Preserves distances Preserves angles Rigid / Euclidean Identity Translation Rotation
Transformation : Similitudes / Similarity Transforms Similarity Transformations Preserves angles Translation, Rotation, Isotropic scaling Similitudes Rigid / Euclidean Identity Translation Isotropic Scaling Rotation
Transformation : Linear Transformations Similitudes Linear Rigid / Euclidean Scaling Identity Translation Isotropic Scaling Reflection Rotation Shear Translation is not linear
Transformation : Affine Transformations preserves parallel lines Affine Similitudes Linear Rigid / Euclidean Scaling Identity Translation Isotropic Scaling Reflection Rotation Shear
Transformation : Projective Transformations preserves lines Projective Affine Similitudes Linear Rigid / Euclidean Scaling Identity Translation Isotropic Scaling Reflection Rotation Shear Perspective
Projective Transformations Affine transformation Projective warps Properties of projective transformations Origin does not necessarily map to origin Lines map to lines Parallel line do not necessarily remain parallel Ratios are not preserved (but “cross-ratios” are) Closed under composition
Cross-ratio Given any four points A, B, C, and D, taken in order, define their cross ratio as Cross Ratio (ABCD) = cross ratio (ABCD) = cross ratio (A'B'C'D')
Matrix Composition Transformations can be combined by matrix multiplication
Matrix Composition Matrices are a convenient and efficient way to represent a sequence of transformations General purpose representations Hardware matrix multiply Efficiency with premultiplication
Matrix Composition Be aware: order of transformations matter Matrix multiplication is not commutative “Global” “Local”
Non-commutative Composition Scale then Translate: p' = T ( S p ) = TS p (5,3) Scale(2,2) (2,2) Translate(3,1) (1,1) (3,1) (0,0) (0,0) Translate then Scale: p' = S ( T p ) = ST p (8,4) Translate(3,1) (4,2) Scale(2,2) (1,1) (6,2) (3,1) (0,0)
Matrix Composition Rotate by q around arbitrary point (a, b) M = T(a, b)* R(q) * T(-a, -b) Translate (a, b) to the origin do the rotation about origin translate back Scale by sx, sy around arbitrary point (a, b) M = T(a, b)* S(sx, sy) * T(-a, -b) do the scale about origin
Transformation Game
Overview 2D Transformation 3D Transformation Basic 2D transformations Matrix representation Matrix Composition 3D Transformation Basic 3D transformations Same as 2D Transformation Hierarchies Scene graphs Ray casting
3D Transformations Same idea as 2D transformations Homogeneous coordinates: (x, y, z, w) 4 x 4 transformation matrices
Basic 3D transformations
Basic 3D transformations
Non-commutative Composition : Order of Rotations Order of Rotation Affects Final Position X-axis Z-axis Z-axis X-axis
Matrix Composition : Rotations in space Rotation about an Arbitrary Axis Rotate about some arbitrary a through angle Rotate about the z axis through an angle The axis a lies in the yz plane Rotate about the x axis through an angle The axis a coincident with the z axis Rotate about the a axis through Same as a rotation about the now coincident z axis Reverse the second rotation about the x axis Reverse the first rotation about the z axis Returning the axis a to its original position z a y x
Transformation Hierarchies Scene may have hierarchy of coordinate systems Each level stores matrix representing transformation from parent’s coordinate system
Transformation Example 1 Well-suited for humanoid characters
Transformation Example 1 Ref] Princeton University
Transformation Example 2 An object may appear in a scene multiple times
Transformation Example 2
Summary Coordinate systems World coordinates Modeling coordinates Representations of 3D modeling transformations 4 x 4 Matrices Scale, rotate, translate, shear, projections, etc. Not arbitrary warps Composition of 3D transformations Matrix multiplication (order matters) Transformation hierarchies