Last week Machiraju/Zhang/Möller/Fuhrmann 1
Geometry basics Scalar, point, and vector Vector space and affine space Basic point and vector operations Sided-ness test Lines, planes, and triangles Linear independence Coordinate systems and frames Machiraju/Zhang/Möller/Fuhrmann 2
From one CS to another Express point given in one frame/cs in another CS In 2D, need to solve system of two equations Assume the two CS have the same origin P = (1, 2) T P = (x, y) T Basis: (1, 1) T and (0, 1) T New set of basis: (-1,1) T and (1, 0) T Need to find x and y such that 1*(1,1) T + 2*(0,1) T = x*(-1,1) T + y*(1,0) T Alternatively (in matrix notation) Machiraju/Zhang/Möller/Fuhrmann 3
2D Transformations Introduction to Computer Graphics Torsten Möller Machiraju/Zhang/Möller/Fuhrmann
Graphics Pipeline Hardware Modelling Transform Visibility Illumination + Shading Perception, Interaction Texture/ Color Realism Machiraju/Zhang/Möller/Fuhrmann 5
Reading Chapter 4 of Angel Chapter 10 of Foley, van Dam, Machiraju/Zhang/Möller/Fuhrmann 6
Schedule Geometry basics Affine transformations Use of homogeneous coordinates Concatenation of transformations 3D transformations Transformation of coordinate systems Transform the transforms Transformations in OpenGL Machiraju/Zhang/Möller/Fuhrmann 7
Basic transformations The most basic ones Translation Scaling Rotation Shear And others, e.g., perspective transform, projection, etc. Basic types of transformations Rigid-body: preserves length and angle Affine: preserves parallel lines, not angles or lengths Free-form: anything goes Machiraju/Zhang/Möller/Fuhrmann 8
Translation in 2D Machiraju/Zhang/Möller/Fuhrmann 9
Scaling in 2D Machiraju/Zhang/Möller/Fuhrmann 10
Rotation about origin Positive angles: counterclockwise For negative angles Machiraju/Zhang/Möller/Fuhrmann 11
Derivation of rotation matrix Make use of polar coordinates: Machiraju/Zhang/Möller/Fuhrmann 12
Shearing in 2D Machiraju/Zhang/Möller/Fuhrmann 13
Schedule Geometry basics Affine transformations Use of homogeneous coordinates Concatenation of transformations 3D transformations Transformation of coordinate systems Transform the transforms Transformations in OpenGL Machiraju/Zhang/Möller/Fuhrmann 14
Homogeneous coordinates Only translation cannot be expressed as matrix-vector multiplications But we can add a third coordinate Homogeneous coordinates for 2D points (x, y) turns into (x, y, W) if (x, y, W) and (x', y', W ) are multiples of one another, they represent the same point typically, W 0. points with W = 0 are points at infinity Machiraju/Zhang/Möller/Fuhrmann 15
2D Homogeneous Coordinates Cartesian coordinates of the homogenous point (x, y, W): x/w, y/w (divide through by W) Our typical homogenized points: (x, y, 1) Connection to 3D? (x, y, 1) represents a 3D point on the plane W = 1 A homogeneous point is a line in 3D, through the origin Machiraju/Zhang/Möller/Fuhrmann 16
Transformation in homogeneous coordinates General form of affine (linear) transformation E.g., 2D translation in homogeneous coordinates Machiraju/Zhang/Möller/Fuhrmann 17
Basic 2D transformations Machiraju/Zhang/Möller/Fuhrmann 18
Inverse of transformations Inverse of T(dx, dy): T( dx, dy) T( dx, dy) = T(dx, dy) 1 R(θ) 1 = R( θ) S(sx, sy) 1 = S(1/sx, 1/sy) Sh(ax) 1 = Sh( ax) Machiraju/Zhang/Möller/Fuhrmann 19
Duality 2D line equation Duality of 3D points to a line 3D plane equation: Duality of 4D points to a plane Machiraju/Zhang/Möller/Fuhrmann 20
Schedule Geometry basics Affine transformations Use of homogeneous coordinates Concatenation of transformations 3D transformations Transformation of coordinate systems Transform the transforms Transformations in OpenGL Machiraju/Zhang/Möller/Fuhrmann 21
Compound transformations Often we need many transforms to build objects (or to direct them) e.g., rotation about an arbitrary point/line? Concatenate basic transforms sequentially This corresponds to multiplication of the transform matrices, thanks to homogeneous coordinates Machiraju/Zhang/Möller/Fuhrmann 22
Compound translation What happens when a point goes through T(d x1, d y1 ) and then T(d x2, d y2 )? Combined translation: T(d x1 +d x2, d y1 +d y2 ) Concatenation of transformations: matrix multiplication Machiraju/Zhang/Möller/Fuhrmann 23
Compound rotation What happens when a point goes through R(θ) and then R(φ)? Combined rotation: R(θ + φ) Scaling or shearing (in one direction) is similar These concatenations are commutative Machiraju/Zhang/Möller/Fuhrmann 24
Commutativity Transformations that do commute: Translate translate Rotate rotate (around the same axis) Scale scale Uniform scale rotate Shear in x (y) shear in x (y), etc. In general, the order in which transformations are composed is important After all, matrix multiplications are not commutative Machiraju/Zhang/Möller/Fuhrmann 25
Commutativity the order in which we compose matrices is important: matrix multiplication does not commute y y y z X then Z x z x z x y y Z then X z x z x Machiraju/Zhang/Möller/Fuhrmann 26
Example (X3d) Machiraju/Zhang/Möller/Fuhrmann
Rotation about an arbitrary point Break it down into easier problems: Translate to the origin: T( x1, y1) Rotate: R(q) And translate back: T(x1, y1) Machiraju/Zhang/Möller/Fuhrmann 28
Rotation about an arbitrary point Compound transformation (non-commutative): T(x1, y1) R(q) T( x1, y1) P = T(x1, y1)r(q)t( x1, y1)p = AP Why combine these matrices into a single A? Machiraju/Zhang/Möller/Fuhrmann 29
Another example Compound transformation: T(x2, y2) R(90 o ) S(sx, sy) T( x1, y1) Machiraju/Zhang/Möller/Fuhrmann 30
Rigid-body transformation A transformation matrix where the upper 2 2 submatrix is orthonormal, preserves angles and lengths called rigid-body transformation any sequence of translation and rotation give a rigid-body transformation Machiraju/Zhang/Möller/Fuhrmann 31
Affine transformation Preserves parallelism, not lengths or angles Unit cube Rot( 45 o ) Scale in x Product of a sequence of translation, scaling, rotation, and shear is affine Machiraju/Zhang/Möller/Fuhrmann 32
Types of Transforms Classification: Euclidean (preserves angles) translation, rotation, uniform scale Affine (preserves parallel lines) Euclidean plus non-uniform scale, shearing Projective (preserves lines) Isometry (preserves distance) Reflection, rigid body motion Nonlinear (lines become curves) Twists, Bends, warps, morphs Machiraju/Zhang/Möller/Fuhrmann 33
Window-To-Viewport Transformation Important example of compound transform World coords : space users work in need to map world to the screen window in world-coordinate space and viewport in screen coordinate space Machiraju/Zhang/Möller/Fuhrmann 34
Window-To-Viewport Transformation (2) one can specify non-uniform scaling results in distorted images What property of window and viewport indicates whether the mapping will distort the images? Machiraju/Zhang/Möller/Fuhrmann 35
Window-To-Viewport Transformation (3) Specify transform in matrix form Machiraju/Zhang/Möller/Fuhrmann 36
Next Lecture: 3-dimensional transformations Homogeneous coordinates Machiraju/Zhang/Möller/Fuhrmann