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

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

Lecture 5 2D Transformation

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

Overview of Projections: From a 3D world to a 2D screen.

Vector Algebra Transformations. Lecture 4

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

2D TRANSFORMATIONS AND MATRICES

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

Section III: TRANSFORMATIONS

Lecture 4: Transforms. Computer Graphics CMU /15-662, Fall 2016

UNIT 2 2D TRANSFORMATIONS

Computer Graphics: Geometric Transformations

Computer Graphics Geometric Transformations

Transforms. COMP 575/770 Spring 2013

Graphics and Interaction Transformation geometry and homogeneous coordinates

COMP30019 Graphics and Interaction Transformation geometry and homogeneous coordinates

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

Overview. By end of the week:

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

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

CT5510: Computer Graphics. Transformation BOCHANG MOON

Affine Transformation. Edith Law & Mike Terry

2D and 3D Transformations AUI Course Denbigh Starkey

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

Computer Science 336 Fall 2017 Homework 2

CS4620/5620. Professor: Kavita Bala. Cornell CS4620/5620 Fall 2012 Lecture Kavita Bala 1 (with previous instructors James/Marschner)

AH Matrices.notebook November 28, 2016

Lecture 6 Sections 4.3, 4.6, 4.7. Wed, Sep 9, 2009

Geometric Transformations

COMP30019 Graphics and Interaction Three-dimensional transformation geometry and perspective

Answers to practice questions for Midterm 1

Computer Graphics Hands-on

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

CS770/870 Spring 2017 Transformations

Unit 3 Transformations and Clipping

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

XPM 2D Transformations Week 2, Lecture 3

Homework 5: Transformations in geometry

GEOMETRIC OBJECTS AND TRANSFORMATIONS I

Computer Graphics 7: Viewing in 3-D

521493S Computer Graphics Exercise 2 Solution (Chapters 4-5)

So we have been talking about 3D viewing, the transformations pertaining to 3D viewing. Today we will continue on it. (Refer Slide Time: 1:15)

Hello, welcome to the video lecture series on Digital Image Processing. So in today's lecture

Graphics Pipeline 2D Geometric Transformations

Perspective projection and Transformations

XPM 2D Transformations Week 2, Lecture 3

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

Geometric transformations assign a point to a point, so it is a point valued function of points. Geometric transformation may destroy the equation

C O M P U T E R G R A P H I C S. Computer Graphics. Three-Dimensional Graphics I. Guoying Zhao 1 / 52

Coordinate transformations. 5554: Packet 8 1

DRAFT: Mathematical Background for Three-Dimensional Computer Graphics. Jonathan R. Senning Gordon College

2D Object Definition (1/3)

Today. Parity. General Polygons? Non-Zero Winding Rule. Winding Numbers. CS559 Lecture 11 Polygons, Transformations

Institutionen för systemteknik

CS-321 Thursday 12 September 2002 Quiz (3 pts.) What is the purpose of a control grid in a cathode ray tube (CRT)?

Homogeneous Coordinates and Transformations of the Plane

1 Affine and Projective Coordinate Notation

2D/3D Geometric Transformations and Scene Graphs

To Do. Outline. Translation. Homogeneous Coordinates. Foundations of Computer Graphics. Representation of Points (4-Vectors) Start doing HW 1

Computer Graphics Hands-on

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

CS4670: Computer Vision

Transformations. Examples of transformations: shear. scaling

Transformations with Matrices Moved by Matrices

Homework 5: Transformations in geometry

Matrix Transformations The position of the corners of this triangle are described by the vectors: 0 1 ] 0 1 ] Transformation:

CS452/552; EE465/505. Geometry Transformations

Linear transformations Affine transformations Transformations in 3D. Graphics 2009/2010, period 1. Lecture 5: linear and affine transformations

Matrices. Chapter Matrix A Mathematical Definition Matrix Dimensions and Notation

Lecture 9: Transformations. CITS3003 Graphics & Animation

Advanced Computer Graphics Transformations. Matthias Teschner

Section 10.1 Polar Coordinates

Game Engineering CS S-05 Linear Transforms

Video of BALSA Scanline Poly Fill Algorithm Animator CS 460. Computer Graphics. Scanline Polygon Fill Algorithm

Game Engineering: 2D

CV: 3D sensing and calibration

Transformations Week 9, Lecture 18

CMSC427: Computer Graphics Lecture Notes Last update: November 21, 2014

Perspective Projection in Homogeneous Coordinates

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

Camera Model and Calibration

3-D D Euclidean Space - Vectors

CSE152a Computer Vision Assignment 1 WI14 Instructor: Prof. David Kriegman. Revision 0

2D and 3D Coordinate Systems and Transformations

Rectification and Distortion Correction

GEOMETRIC TRANSFORMATIONS AND VIEWING

CSE528 Computer Graphics: Theory, Algorithms, and Applications

Introduction to Homogeneous coordinates

2D Geometric Transformations and Matrices

CS 4620 Midterm 1. Tuesday 22 October minutes

window World space (Object space)

Early Fundamentals of Coordinate Changes and Rotation Matrices for 3D Computer Vision

Forward kinematics and Denavit Hartenburg convention

Last week. Machiraju/Zhang/Möller

Coordinate Transformations & Homogeneous Coordinates

N-Views (1) Homographies and Projection

Specifying Complex Scenes

Modeling Transformations

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

2-9 Operations with Complex Numbers

Transcription:

2D transformations: An introduction to the maths behind computer graphics Lecturer: Dr Dan Cornford d.cornford@aston.ac.uk http://wiki.aston.ac.uk/dancornford CS2150, Computer Graphics, Aston University, Birmingham, UK http://wiki.aston.ac.uk/c2150 October 12, 2009 Dan Cornford 2D Transformations 1/14

Outline: 2D transformations What are we transforming? Why consider 2D transformations? Revision on vectors and matrices. Definition of common 2D affine transformations. Homogeneous coordinates. Dan Cornford 2D Transformations 2/14

2D geometrical transformations Start by considering 2D objects. Later we will consider scan conversion: objects primitives pixels. This section discusses the methods we use to model 2D objects and transformations of those objects: objects objects. In 2D, possible primitives are points, lines and polygons, which can be combined to give higher level objects. In 2D it is generally easy to see how to represent certain objects. To understand transformations we need to use basic vector algebra! Dan Cornford 2D Transformations 3/14

Vectors A vector is an n-tuple of numbers: [ ] 2 r =. 3 Vectors are denoted by lower case bold letters. The rule for the addition is: r 1 s 1 r 1 + s 1 r + s = r 2 + s 2 = r 2 + s 2. r 3 s 3 r 3 + s 3 Vector addition is commutative: r + s = s + r. Dan Cornford 2D Transformations 4/14

2D transformations Use the vector and matrix algebra. Translations are offsets from the existing position of the object. Consider a point at r. Translate it by an amount t = (t x, t y ) : new location will be r = r + t. Before translation After translation Dan Cornford 2D Transformations 5/14

Matrices m p p n A * = m B C n A matrix is a rectangular array of numbers. A general matrix will be represented by an upper case letter: a 1,1 a 1,2 a 1,3 A = a 2,1 a 2,2 a 2,3. a 3,1 a 3,2 a 3,3 The element on the ith row and jth column is denoted by a i,j. Note that we start indexing at 1, whereas C indexes arrays from 0. Dan Cornford 2D Transformations 6/14

2D transformations Scalings are stretchings of the object, about the origin. The scaling matrix S is: [ ] sx 0 S =, 0 s y r = Sr : s x is the x-axis scaling and s y is the y-axis scaling. If s x = s y = s the scaling is said to be uniform. If not the scaling is called differential. Before scaling After scaling Dan Cornford 2D Transformations 7/14

2D transformations implementation In order to apply the scaling we need to multiple each vertex of the object (a vector) by the scaling matrix: [ ] [ ] [ ] [ ] sx 0 r1 sx r Sr = = 1 + 0 r 2 sx r = 1 0 s y 0 r 1 + s y r 2 s y r 2 r 2, It is important to be able to multiply a matrix times a vector: remember the first element of the answer is the sum of the elements of the first row of the vector times the original vector. Dan Cornford 2D Transformations 8/14

2D transformations Rotations about the origin by an angle θ are defined by the rotation matrix R which is given by: [ ] cos θ sin θ R =. sin θ cos θ The rotated point, r = Rr. A positive θ implies an anti-clockwise rotation. Before rotation After rotation Dan Cornford 2D Transformations 9/14

Homogeneous coordinates Homogeneous coordinates allow us to treat all transformations in the same way, as matrix multiplications. The consequence is that our 2-vectors become extended to 3-vectors, with a resulting increase in storage and processing. We represent a point (x, y) by the extended triple (x, y, w). The normalised homogeneous coordinates are (x/w, y/w, 1). Points with w = 0 are called points at infinity, and are not frequently used. If you like then you can think of 2D space corresponding to the plane w = 1. Dan Cornford 2D Transformations 10/14

Homogeneous coordinates In homogeneous coordinates the transformations are: translation: r = x y = 1 0 t x 0 1 t y x y = T r ; 1 0 0 1 1 scaling: x s x 0 0 x r = y = 0 s y 0 y = Sr ; 1 0 0 1 1 rotation: r = x cos θ sin θ 0 y = sin θ cos θ 0 x y = Rr. 1 0 0 1 1 Dan Cornford 2D Transformations 11/14

Homogeneous coordinates Apply each of these transformations to a vector [x, y, 1] ] and compute the resulting vector: translation: 1 0 t x x? 0 1 t y y =? ; 0 0 1 1? scaling: rotation: s x 0 0 x? 0 s y 0 y =? ; 0 0 1 1? cos θ sin θ 0 x? sin θ cos θ 0 y =?. 0 0 1 1? Dan Cornford 2D Transformations 12/14

Homogeneous coordinates Rigid body transformations preserve length and angles (e.g. translation or rotation). Affine transformations preserve parallelism in lines (e.g. translation, rotation, scaling and shearing). A shear transformation is given by: x 1 h x 0 x r = y = h y 1 0 y = Hr, 1 0 0 1 1 h x and h y represent the amount of shear along the x and y axes respectively. Dan Cornford 2D Transformations 13/14

Summary Having finished this lecture you should: be able to write down the transformation matrices in both Cartesian (normal) and homogeneous coordinates; understand the role of homogeneous coordinates in computer graphics; be able to multiply a vector (vertex) by a matrix (transformation). In the exam I often ask you to apply transformations to simple objects, typically in 2D, so you need to know how to do this! Dan Cornford 2D Transformations 14/14