Transformation CS 148: Summer 2016 Introduction of Graphics and Imaging Zahid Hossain http://www.pling.org.uk/cs/cgv.html
Placement of Objects Fisher et al. (2012) 2 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Placement of Objects Oriented Fisher et al. (2012) 3 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Placements of Objects Translated Fisher et al. (2012) 4 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Points and Vectors y p x Origin z 5 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Points and Vectors y x Vector Points Origin z 6 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Transformations What? Just functions acting on points: • Why? • • Viewing: • Convert between coordinates systems • Virtual camera, e.g. perspective projections • Modeling: • Create objects in a convenient orientation • Use multiple instances of a given shape • Kinematics – characters/robots 7
Linear Transformation 8 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Linear Transformation 9 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Linear Transformation 10 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Linear Transformation Lines Map to Lines 11 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Common Transformation Rotate Scale Shear 12
13
Composing Transformations First Rotate 45° 14 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Composing Transformations Then Scale 2x along y 15 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Composing Transformations Scale Rotation Order of transformations 16 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Composing Transformation Not Commutative Rotate -> Scale Scale -> Rotate 17 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Translation 18 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Homogenous Coordinates For any non-zero c 19 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Homogenous Coordinates 20 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Homogenous Coordinates 21 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Homogenous Coordinates 4D Homogenous Coordinate 3D Cartesian Coordinate 22 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Homogenous Coordinates (x,y,w) w-axis w=1 (x/w,y/w,1) x,y-axis 23 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Homogenous Coordinates z-axis Decrease w z=1 x,y-axis 24 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Homogenous Coordinates z-axis Decrease w z=1 x,y-axis 25 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Homogenous Coordinates 26 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Homogenous Coordinates Represents a Vector! (Homogenous Coordinates express both Vectors and Points) 27 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Back to Translation Homogenous Coordinate Homogenous Coordinate 28 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Some Exercise Convert 3D Cartesian Coordinate to Homogenous Coordinate (3,4,2) : 29 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Some Exercise Convert 3D Cartesian Coordinate to Homogenous Coordinate (3,4,2) : (3,4,2,1) 30 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Some Exercise Convert 3D Cartesian Coordinate to Homogenous Coordinate (3,4,2) : (3,4,2,1) Convert Homogenous Coordinate to Cartesian Coordinate (3,4,2,2) : 31 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Some Exercise Convert 3D Cartesian Coordinate to Homogenous Coordinate (3,4,2) : (3,4,2,1) Convert Homogenous Coordinate to Cartesian Coordinate (3,4,2,2) : (1.5,2,1) 32 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Some Exercise Rotate about the center of the box 33 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Some Exercise Translate to center 34 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Some Exercise Rotate 35 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Some Exercise Translate back 36 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Coordinate System 37 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Coordinate System 38 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Coordinate System 39 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Coordinate System: Rotation 40 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Coordinate System: Rotation 41 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Coordinate System: Rotation 42 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Coordinate System: Hierarchy 43 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Coordinate System: Hierarchy 44 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Coordinate System: Hierarchy 45 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Interpreting Transformations 46 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Two Interpretations • With respect to Global Frame • With respect to Local Frame 47 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Coordinate System: Hierarchy 48 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
w.r.t Global Frame Rotate(45°) Translate(0,1) Translate(1,1) Combined = Translate(0,1) Rotate(45°) Translate(1,1) Order of Transforms 49 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
w.r.t Local Frame Rotate(45°) Translate(1,1) Translate(0,1) Combined = Translate(0,1) Rotate(45°) Translate(1,1) Order of Transform 50 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
w.r.t Local Frame Rotate(45°) Translate(1,1) Translate(0,1) Combined = Translate(0,1) Rotate(45°) Translate(1,1) Order of Transform Both interpretations are equivalent 51 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Hierarchical Modeling translate(0,4) drawTorso() pushMatrix() translate(1.5,0) rotateX(leftHipRotate) drawThigh() pushMatrix() translate(0,-2) rotateX(leftKneeRotate) drawLeg() ... popMatrix() popMatrix() pushMatrix() y translate(-1.5,0) rotateX(rightHipRotate) // Draw the right side x Matrix Stack ... ... CurrentMatrix = Translate(0,4) 52 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Hierarchical Modeling translate(0,4) drawTorso() pushMatrix() translate(1.5,0) rotateX(leftHipRotate) drawThigh() pushMatrix() translate(0,-2) rotateX(leftKneeRotate) drawLeg() ... popMatrix() popMatrix() pushMatrix() y translate(-1.5,0) rotateX(rightHipRotate) Translate(0,4) // Draw the right side x Matrix Stack ... ... CurrentMatrix = Translate(0,4) 53 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Hierarchical Modeling translate(0,4) drawTorso() pushMatrix() translate(1.5,0) rotateX(leftHipRotate) drawThigh() pushMatrix() translate(0,-2) rotateX(leftKneeRotate) drawLeg() ... popMatrix() popMatrix() pushMatrix() y translate(0,4) translate(1.5,0) rotateX(leftHipRotate) translate(-1.5,0) rotateX(rightHipRotate) translate(0,4) // Draw the right side x Matrix Stack ... ... CurrentMatrix = translate(0,4) translate(1.5,0) rotateX(leftHipRotate) translate(0,-2) rotate(leftKneeRotate) 54 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Recommend
More recommend