Computer Graphics 3: 2D Transformations

Slides:



Advertisements
Similar presentations
Computer Graphics: 2D Transformations
Advertisements

Gursharan Singh Tatla TRANSFORMATIONS Gursharan Singh Tatla Gursharan Singh Tatla.
Picture Manipulation The manipulation of (already created) pictures. May be applied to vector graphics or bitmaps. We will consider bitmaps and introduce.
CMPE 466 COMPUTER GRAPHICS
1 CSCE 441 Computer Graphics: 2D Transformations Jinxiang Chai.
1 of 19 New Lecture And Lab Information Lectures: –Thursday 13:00 – 14:00 (A322) Does anyone miss lunch? –Friday 15:00 – 16:00 (A28) Labs: –Wednesday 10:00.
CSCE 590E Spring 2007 Basic Math By Jijun Tang. Applied Trigonometry Trigonometric functions  Defined using right triangle  x y h.
Computer Graphics CSC 630 Lecture 2- Linear Algebra.
Course Website: Computer Graphics 3: 2D Transformations.
Rotations and Translations. Representing a Point 3D A tri-dimensional point A is a reference coordinate system here.
Computer Graphics with OpenGL 3e
1 of 23 New Lecture And Lab Information Lectures: –Thursday 12:00 – 13:00 (room tba) –Friday 15:00 – 16:00 (A28) Labs: –Wednesday 10:00 – 11:00 (A305)
2D Transformations x y x y x y. 2D Transformation Given a 2D object, transformation is to change the object’s Position (translation) Size (scaling) Orientation.
Geometric Transformation-2D
2D Transformations Unit - 3. Why Transformations? In graphics, once we have an object described, transformations are used to move that object, scale it.
3D Graphics Goal: To produce 2D images of a mathematically described 3D environment Issues: –Describing the environment: Modeling (mostly later) –Computing.
Transformations Aaron Bloomfield CS 445: Introduction to Graphics
Geometric Transformation. So far…. We have been discussing the basic elements of geometric programming. We have discussed points, vectors and their operations.
Lecture Notes: Computer Graphics.
Mathematics for Computer Graphics. Lecture Summary Matrices  Some fundamental operations Vectors  Some fundamental operations Geometric Primitives:
Computer Graphics World, View and Projection Matrices CO2409 Computer Graphics Week 8.
Dx = 2 dy = 3 Y X D Translation A translation is applied to an object by repositioning it along a straight-line path.
Geometric Transformations
Spatial Descriptions and Transformations Sebastian van Delden USC Upstate
Computer Graphics 2D Transformations. 2 of 74 Contents In today’s lecture we’ll cover the following: –Why transformations –Transformations Translation.
1 Computer Graphics Week9 -3D Geometric Transformation.
16/5/ :47 UML Computer Graphics Conceptual Model Application Model Application Program Graphics System Output Devices Input Devices API Function.
Geometrical Transformations 2 Adapted from Fundamentals of Interactive Computer Graphics, Foley and van Dam, pp , by Geb Thomas.
1 Graphics CSCI 343, Fall 2015 Lecture 10 Coordinate Transformations.
Affine Transformation. Affine Transformations In this lecture, we will continue with the discussion of the remaining affine transformations and composite.
Transformations CS 445/645 Introduction to Computer Graphics David Luebke, Spring 2003.
Honors Geometry.  We learned how to set up a polygon / vertex matrix  We learned how to add matrices  We learned how to multiply matrices.
1 Teaching Innovation - Entrepreneurial - Global The Centre for Technology enabled Teaching & Learning, N Y S S, India DTEL DTEL (Department for Technology.
Geometric Transformations Ceng 477 Introduction to Computer Graphics Computer Engineering METU.
Computer Graphic 2 D Transformation.
CSCE 441 Computer Graphics: 2D Transformations
Modeling Transformation
Transformations. Modeling Transformations  Specify transformations for objects  Allows definitions of objects in own coordinate systems  Allows use.
COMPUTER GRAPHICS AND LINEAR ALGEBRA AN INTRODUCTION.
2D Geometry - points and polygons
CPT450 – Computer Graphics
Computer Graphics 2D Transformations
Modeling Transformations
Lecture 10 Geometric Transformations In 3D(Three- Dimensional)
Transforms.
Computer Graphics 3: 2D Transformations
Chapter 7 Matrix Mathematics
Geometric Transformations Hearn & Baker Chapter 5
2D Geometric Transformations
Computer Graphics CC416 Week 15 3D Graphics.
Computer Graphics Transformations.
3D Geometric Transformations
CS1550 Fundamentals For Computer Graphics Transformations-1
Chapter 5 2-D Transformations.
Computer Graphics Transformations.
Introduction to Computer Graphics CS 445 / 645
Lecture 7 Geometric Transformations (Continued)
2D Transformations y y x x y x.
© 2008, Fayyaz A. Afsar, DCIS, PIEAS.
Linear Algebra Review.
Lecture 03: Linear Algebra
COMP 175: Computer Graphics February 9, 2016
CSC4820/6820 Computer Graphics Algorithms Ying Zhu Georgia State University Transformations.
Transformations 3 University of British Columbia
Chapter IV Spaces and Transforms
COMP 175: Computer Graphics February 21, 2016
New Lecture And Lab Information
(c) University of Wisconsin, CS559
TWO DIMENSIONAL TRANSFORMATION
Translation in Homogeneous Coordinates
Presentation transcript:

Computer Graphics 3: 2D Transformations

Contents In today’s lecture we’ll cover the following: Why transformations Transformations Translation Scaling Rotation Homogeneous coordinates Matrix multiplications Combining transformations

Why Transformations? In graphics, once we have an object described, transformations are used to move that object, scale it and rotate it Images taken from Hearn & Baker, “Computer Graphics with OpenGL” (2004)

Translation Simply moves an object from one position to another xnew = xold + dx ynew = yold + dy Note: House shifts position relative to origin y x 1 2 3 4 5 6 7 8 9 10

Translation Example y x (2, 3) (1, 1) (3, 1) 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 (2, 3) Translate by (5, 3) x’ = x + dx y’ = y + dy (1, 1) (3, 1)

Scaling Scalar multiplies all coordinates WATCH OUT: Objects grow and move! xnew = Sx × xold ynew = Sy × yold Note: House shifts position relative to origin y x 1 2 3 4 5 6 7 8 9 10

Scaling Example y (2, 3) (1, 1) (3, 1) 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 (2, 3) Scale by (2, 2) x’ = sx*x y’ = sy*y (1, 1) (3, 1)

Rotation Rotates all coordinates by a specified angle xnew = xold × cosθ – yold × sinθ ynew = xold × sinθ + yold × cosθ Points are always rotated about the origin y 6 5 4 3 2 1 x 1 2 3 4 5 6 7 8 9 10

Rotation Example y (4, 3) (3, 1) (5, 1) 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 (4, 3) xnew = xold × cosθ – yold × sinθ ynew = xold × sinθ + yold × cosθ 1 radian = 180/π degrees cos(π/6)=0.866 sin(π/6)=0.5 x’(4, 3) = 4*0.866 – 3*0.5 = 3.46 – 1.5 = 1.96 y’(4, 3) = 4*0.5 + 3*0.866 = 2.0 + 2.598 = 4.598 x’(3, 1) = 3*0.866 – 1*0.5 = 2.598 – 0.5 = 2.098 y’(3, 1) = 3*0.5 + 1*0.866 = 1.5 + 0.866 = 2.366 x’(5, 1) = 5*0.866 – 1*0.5 = 4.33 – 0.5 = 3.83 y’(5, 1) = 5*0.5 + 1*0.866 = 2.5 + 0.866 = 3.366 (3, 1) (5, 1)

Homogeneous Coordinates A point (x, y) can be re-written in homogeneous coordinates as (xh, yh, h) The homogeneous parameter h is a non- zero value such that: We can then write any point (x, y) as (hx, hy, h) We can conveniently choose h = 1 so that (x, y) becomes (x, y, 1)

Why Homogeneous Coordinates? Mathematicians commonly use homogeneous coordinates as they allow scaling factors to be removed from equations We will see in a moment that all of the transformations we discussed previously can be represented as 3*3 matrices Using homogeneous coordinates allows us use matrix multiplication to calculate transformations – extremely efficient!

Homogeneous Translation The translation of a point by (dx, dy) can be written in matrix form as: Representing the point as a homogeneous column vector we perform the calculation as:

Remember Matrix Multiplication Recall how matrix multiplication takes place:

Homogenous Coordinates To make operations easier, 2-D points are written as homogenous coordinate column vectors Translation: Scaling:

Homogenous Coordinates (cont…) Rotation:

Inverse Transformations Transformations can easily be reversed using inverse transformations

Combining Transformations A number of transformations can be combined into one matrix to make things easy Allowed by the fact that we use homogenous coordinates Imagine rotating a polygon around a point other than the origin Transform to centre point to origin Rotate around origin Transform back to centre point

Combining Transformations (cont…) 1 2 3 4

Combining Transformations (cont…) The three transformation matrices are combined as follows REMEMBER: Matrix multiplication is not commutative so order matters

Summary In this lecture we have taken a look at: 2D Transformations Translation Scaling Rotation Homogeneous coordinates Matrix multiplications Combining transformations Next time we’ll start to look at how we take these abstract shapes etc and get them on-screen

Exercises 1 Translate the shape below by (7, 2) y (2, 3) (1, 2) (3, 2) 1 2 3 4 5 6 7 8 9 10 (2, 3) (1, 2) (3, 2) (2, 1) x

Exercises 2 Scale the shape below by 3 in x and 2 in y y (2, 3) (1, 2) 1 2 3 4 5 6 7 8 9 10 (2, 3) (1, 2) (3, 2) (2, 1) x

Exercises 3 Rotate the shape below by 30° about the origin y (7, 3) 1 2 3 4 5 6 7 8 9 10 (7, 3) (6, 2) (8, 2) (7, 1) x

Exercise 4 Write out the homogeneous matrices for the previous three transformations Translation Scaling Rotation

Exercises 5 Using matrix multiplication calculate the rotation of the shape below by 45° about its centre (5, 3) x y 1 2 3 4 5 6 7 8 9 10 (5, 4) (6, 3) (4, 3) (5, 2)

Scratch y 1 2 3 4 5 6 7 8 9 10 x

Equations xnew = xold + dx ynew = yold + dy Translation: Scaling: xnew = Sx × xold ynew = Sy × yold Rotation xnew = xold × cosθ – yold × sinθ ynew = xold × sinθ + yold × cosθ