Affine Transformation. Edith Law & Mike Terry

Similar documents
Affine Transformations. Transforming shape models Combining affine transformations Scene graphs, interactor trees Hit tests on transformed shapes

Graphics Transformations

Vector Algebra Transformations. Lecture 4

2D Image Transforms Computer Vision (Kris Kitani) Carnegie Mellon University

2D transformations: An introduction to the maths behind computer graphics

GEOMETRIC TRANSFORMATIONS AND VIEWING

Modeling Transformations

Graphics Hit-testing. Shape Models Selecting Lines and Shapes. 2.7 Graphics Hit-testing 1

Computer Science 336 Fall 2017 Homework 2

UNIT 2 2D TRANSFORMATIONS

2D TRANSFORMATIONS AND MATRICES

Graphics and Interaction Transformation geometry and homogeneous coordinates

COMP30019 Graphics and Interaction Transformation geometry and homogeneous coordinates

Coordinate transformations. 5554: Packet 8 1

Computer Graphics Geometric Transformations

Transforms. COMP 575/770 Spring 2013

2D and 3D Transformations AUI Course Denbigh Starkey

CALCULATING TRANSFORMATIONS OF KINEMATIC CHAINS USING HOMOGENEOUS COORDINATES

Transformations. Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico

Warping. 12 May 2015

Overview. Affine Transformations (2D and 3D) Coordinate System Transformations Vectors Rays and Intersections

EECE 478. Learning Objectives. Learning Objectives. Linear Algebra and 3D Geometry. Linear algebra in 3D. Coordinate systems

3D Mathematics. Co-ordinate systems, 3D primitives and affine transformations

Core Graphics and OpenGL ES. Dr. Sarah Abraham

2D/3D Geometric Transformations and Scene Graphs

3D Computer Graphics. Jared Kirschner. November 8, 2010

Math background. 2D Geometric Transformations. Implicit representations. Explicit representations. Read: CS 4620 Lecture 6

Computer Graphics: Geometric Transformations

Transformations Computer Graphics I Lecture 4

Last week. Machiraju/Zhang/Möller/Fuhrmann

Transformations. CSCI 420 Computer Graphics Lecture 4

COMP30019 Graphics and Interaction Three-dimensional transformation geometry and perspective

CS 4204 Computer Graphics

Transformation. Jane Li Assistant Professor Mechanical Engineering & Robotics Engineering

3D Transformation. In 3D, we have x, y, and z. We will continue use column vectors:. Homogenous systems:. x y z. x y z. glvertex3f(x, y,z);

Software Engineering. ò Look up Design Patterns. ò Code Refactoring. ò Code Documentation? ò One of the lessons to learn for good design:

Image Warping. Some slides from Steve Seitz

Transformations. CSCI 420 Computer Graphics Lecture 5

Transformations. OpenGL Transformations. 4x4 Model-view Matrix (this lecture) OpenGL Transformation Matrices. 4x4 Projection Matrix (next lecture)

Coordinate Spaces & Transformations. in InDesign CS4 CC Chapter 1

Section III: TRANSFORMATIONS

Transformations Computer Graphics I Lecture 4

Overview. By end of the week:

Image Warping : Computational Photography Alexei Efros, CMU, Fall Some slides from Steve Seitz

CS770/870 Spring 2017 Transformations

2D and 3D Coordinate Systems and Transformations

Object Representation Affine Transforms. Polygonal Representation. Polygonal Representation. Polygonal Representation of Objects

Image warping , , Computational Photography Fall 2017, Lecture 10

UNIT 2. Translation/ Scaling/ Rotation. Unit-02/Lecture-01

AH Matrices.notebook November 28, 2016

Monday, 12 November 12. Matrices

Computer Graphics with OpenGL ES (J. Han) Chapter IV Spaces and Transforms

Interactive Computer Graphics. Hearn & Baker, chapter D transforms Hearn & Baker, chapter 5. Aliasing and Anti-Aliasing

Homework #1. Displays, Image Processing, Affine Transformations, Hierarchical Modeling

Vectors. Vectors are used to talk about positions in 3 dimensional space, differences between one position and another, or directions.

CS 563 Advanced Topics in Computer Graphics. by Emmanuel Agu

BASIC ELEMENTS. Geometry is the study of the relationships among objects in an n-dimensional space

Lesson 28: When Can We Reverse a Transformation?

Linear algebra deals with matrixes: two-dimensional arrays of values. Here s a matrix: [ x + 5y + 7z 9x + 3y + 11z

Modeling Transformations

Homework #2 and #3 Due Friday, October 12 th and Friday, October 19 th

Computer Graphics 7: Viewing in 3-D

CS559 Computer Graphics Fall 2015

Chapter 2 and Supplements MATRICES

Computer Graphics. Lecture 2. Doç. Dr. Mehmet Gokturk

CSE 167: Introduction to Computer Graphics Lecture #2: Coordinate Transformations

CT5510: Computer Graphics. Transformation BOCHANG MOON

Lecture 11: Output 2. Fall UI Design and Implementation 1

Figure 1. Lecture 1: Three Dimensional graphics: Projections and Transformations

Today s class. Geometric objects and transformations. Informationsteknologi. Wednesday, November 7, 2007 Computer Graphics - Class 5 1

1 Affine and Projective Coordinate Notation

6B Quiz Review Learning Targets ,

CSE328 Fundamentals of Computer Graphics: Theory, Algorithms, and Applications

Basics of Computational Geometry

Lecture 9: Transformations. CITS3003 Graphics & Animation

Lecture 4: Transformations and Matrices. CSE Computer Graphics (Fall 2010)

GEOMETRIC OBJECTS AND TRANSFORMATIONS I

speed of light in vacuum = speed of light in the material

Computer Graphics. Chapter 5 Geometric Transformations. Somsak Walairacht, Computer Engineering, KMITL

CS452/552; EE465/505. Transformations

1 Historical Notes. Kinematics 5: Quaternions

Therefore, after becoming familiar with the Matrix Method, you will be able to solve a system of two linear equations in four different ways.

DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI

1. We ll look at: Types of geometrical transformation. Vector and matrix representations

Coordinate Transformations & Homogeneous Coordinates

Modeling Transformations

Today. Today. Introduction. Matrices. Matrices. Computergrafik. Transformations & matrices Introduction Matrices

Chapter 1: Number and Operations

Matrices. A Matrix (This one has 2 Rows and 3 Columns) To add two matrices: add the numbers in the matching positions:

Transformations Week 9, Lecture 18

CS 130 Final. Fall 2015

Transformations. CS 537 Interactive Computer Graphics Prof. David E. Breen Department of Computer Science

Objectives. transformation. General Transformations. Affine Transformations. Notation. Pipeline Implementation. Introduce standard transformations

PetShop (BYU Students, SIGGRAPH 2006)

CS184: Using Quaternions to Represent Rotation

2D Object Definition (1/3)

Moving Objects. We need to move our objects in 3D space.

CS 184, Fall 1992 MT Solutions Professor Brian A. Barsky

COMP3421. Week 2 - Transformations in 2D and Vector Geometry Revision

COMP3421. Week 2 - Transformations in 2D and Vector Geometry Revision

Transcription:

Affine Transformation Edith Law & Mike Terry

Graphic Models vs. Images Computer Graphics: the creation, storage and manipulation of images and their models Model: a mathematical representation of an image containing the important properties of an object (e.g., location, size, orientation, color, texture) in data structures. Rendering: Using the properties of the model to create an image to display on the screen. Image: the rendered model. Model Rendering Image

Example Shape Models An array of points: {P1, P2,, Pn} Can be open, closed, filled

Components For a lightweight GUI toolkit, components maintain a shape model location bounds If a visible component its outline (coordinates or other descriptors for its shape) whether interior should be filled with a color, and if so, what color

Components But components also need to paint themselves in a particular location Location always specified in terms of parent s coordinate system That means we need to do some math before painting and doing hit testing (i.e., determining which components a given location corresponds to) We will use affine transforms to help out

Linear Algebra (s) Scalar: a single value (usually real number) (v) Vector: directed line segment (represents direction and magnitude) (P) Point: a fixed location in space (represents a position) Legal operations: vector + vector: v1 + v2 = v3 vector multiplied by a scalar: v1 x s1 = v4 point minus point = P1 - P2 = v5 point + vector: P2 + v5 = P1 2 ways to multiply vector by vector dot (inner) product: v1 o v2 = s2 cross (outer) product: v1 x v2 = v6

Moving Shapes Around, Multiple Shape Instances Translate by adding offset to shape points What about scaling? Or rotation? transform

Translation translate: add a scalar to each of the components tx=2, ty=4 x' = x + tx y' = y + ty

Uniform Scaling uniform scale: multiply each component by the same scalar multiply by s = 2 x' = x s y' = y s

Non-Uniform Scaling scale: multiply each component by different scalar multiply by sx = 2, sy = 1/2 x' = x sx y' = y sy

Rotation rotate: each component is some function of x, y, Θ rotate by Θ = 30 o Θ x' = f(x,y,θ) y' = f(x,y,θ)

Deriving Rotation Function

Intermission: Super cool and fun rotation derivation

Voila! Rotation rotate: each component is some function of x, y, Θ rotate by Θ = 30 o Θ x' = x cos(θ)-y sin(θ) y' = x sin(θ)+y cos(θ)

Combining Transformations Rotate: x' = x cos(θ)-y sin(θ) y' = x sin(θ)+y cos(θ) Translate: x' = x tx y' = y ty Scale: x' = x sx y' = y sy

Combining Transformations: (1) Scale Rotate: x' = x cos(θ)-y sin(θ) y' = x sin(θ)+y cos(θ) Translate: x' = x + tx y' = y + ty Scale: x' = x sx y' = y sy x1 = 2x y1 = 2y

Combining Transformations: (2) Rotate Rotate: x' = x cos(θ)-y sin(θ) y' = x sin(θ)+y cos(θ) Translate: x' = x + tx y' = y + ty Scale: x' = x sx y' = y sy x2 = 2x cos(30) - 2y sin(30) y2 = 2y sin(30) + 2y sin(30)

Combining Transformations: (3) Translation Rotate: x' = x cos(θ)-y sin(θ) y' = x sin(θ)+y cos(θ) Translate: x' = x + tx y' = y + ty Scale: x' = x sx y' = y sy x3 = 2x cos(30) - 2y sin(30) + 8 y3 = 2y sin(30) + 2y sin(30) + 4 N.B. Order of operations is important. What if you translate first?

Matrix Representation Goal: represent each 2D transformation with a matrix Multiply matrix by column vector <=> apply transformation to point

Matrix Representation Why? Transformations can be combined by multiplication We can multiply transformation matrices together This single matrix can then be used to transform many points. Can be sent to a GPU to speed the process.

2 x 2 Matrices Why types of transformations can be represented by a 2x2 matrix? 2D Scale around (0,0)?

2 x 2 Matrices Why types of transformations can be represented by a 2x2 matrix? 2D Rotate around (0,0)?

2 x 2 Matrices Why types of transformations can be represented by a 2x2 matrix? 2D Mirror about Y axis?

2 x 2 Matrices Why types of transformations can be represented by a 2x2 matrix? 2D Translation Maybe this? 1 / / 1 Problem: only works for a specific point. Can t create a general 2x2 matrix to transform a model.

Homogeneous Coordinates represents coordinates in 2 dimensions with a 3-tuple (i.e., as a 3x1 column matrix) why? need 3 columns in our transformation matrix

3x3 Translation Matrix now we can represent 2D translation with a 3x3 matrix This 3x3 matrix is an Affine Transformation matrix, and can be used to generally handle translation, rotation and scaling.

3x3 Translation Matrix: Example

Homogeneous Coordinate [x, y, w] T represents a point at location [x/w, y/w] T convenient coordinate system to represent many useful transformations [3, 2, 1] T [6, 4, 2] T [7.5, 5, 2.5] T

Vector and Point Homogeneous Coordinates add vectors scalar multiply subtract points point + vector

Translating Vectors a vector has no position so translating it shouldn t change anything.

Rotation Matrix Vectors: Points:

Scaling Matrix Vectors: Points:

Matrix Composition Transformations can be combined by matrix multiplication

Matrix Composition Order Associative: A(BC) = (AB)C not commutative: AB BA order of transformations matters!

Matrix Composition What if we want to rotate and translate? example: rotate line segment by 45 degrees about endpoint a

Multiplication Order: Wrong Way Beginning situation Rotate 45 degrees, R(45) affects both endpoints Could try translating both endpoints to return a to its original position but by how much?

Multiplication Order: Correct Way Scaling and rotation are both about the origin Process: Translate shape to the origin rotate translate back to where you want it

Affine Transformations + Interactor Tree As we descent the interactor tree, component needs to: (1) paint itself (2) for each child save the current affine transform multiply current transform by a translation affine transform representing the location of child component (current transform * new translation transform) set result of that multiplication as the new affine transform tell child to paint themselves return the original affine transform

Affine Transformations + Interactor Tree We also need to transform any coordinates in events as the events are passed down the interactor tree. For example, a mouse event in the window s coordinates will need its coordinates translated to a child component s relative location prior to passing it down. Affine transforms can be used for this, too.

Inside / Hit Tests with Transformed Shapes Mouse and shape model must use the same coordinate system Two options: transform mouse to model coordinates transform model to mouse coordinates

Option 1: Transform Mouse to Model Coordinates only one transformation maintaining the inverse

Option 2: Transform Model to Mouse Coordinates many transformations manipulations (e.g., dragging) must be transformed back into model coordinates