2D Transformations Introduction to Computer Graphics Arizona State University

Similar documents
The Essentials of CAGD

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

Chapter 2 - Basic Mathematics for 3D Computer Graphics

Transforms. COMP 575/770 Spring 2013

Practical Linear Algebra: A Geometry Toolbox

CT5510: Computer Graphics. Transformation BOCHANG MOON

Animation. Keyframe animation. CS4620/5620: Lecture 30. Rigid motion: the simplest deformation. Controlling shape for animation

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

Vector Algebra Transformations. Lecture 4

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

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

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

Homogeneous Coordinates. Lecture18: Camera Models. Representation of Line and Point in 2D. Cross Product. Overall scaling is NOT important.

Practical Linear Algebra: A Geometry Toolbox

CALCULATING TRANSFORMATIONS OF KINEMATIC CHAINS USING HOMOGENEOUS COORDINATES

Geometric Transformations

Graphics and Interaction Transformation geometry and homogeneous coordinates

Animation. CS 4620 Lecture 32. Cornell CS4620 Fall Kavita Bala

2D/3D Geometric Transformations and Scene Graphs

COMP30019 Graphics and Interaction Transformation geometry and homogeneous coordinates

Exercises for Chapter Three You know you've got to exercise your brain just like your muscles. Will Rogers ( )

2D Object Definition (1/3)

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

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

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

METR Robotics Tutorial 2 Week 2: Homogeneous Coordinates

Review of Thursday. xa + yb xc + yd

Homework 5: Transformations in geometry

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

3-D D Euclidean Space - Vectors

Homework 5: Transformations in geometry

2D and 3D Coordinate Systems and Transformations

Game Engineering CS S-05 Linear Transforms

Parallel and perspective projections such as used in representing 3d images.

L6 Transformations in the Euclidean Plane

2D and 3D Transformations AUI Course Denbigh Starkey

Viewing and Projection

CMSC 425: Lecture 6 Affine Transformations and Rotations

Overview. By end of the week:

Computer Vision. Coordinates. Prof. Flávio Cardeal DECOM / CEFET- MG.

CSC418 / CSCD18 / CSC2504

Rotations in 3D Graphics and the Gimbal Lock

OPTI 421/521 Introductory Optomechanical Engineering. 6. Mirror matrices. Matrix formalism is used to model reflection from plane mirrors.

Chapter 9. Linear algebra applications in geometry

Viewing and Projection

calibrated coordinates Linear transformation pixel coordinates

COMP30019 Graphics and Interaction Three-dimensional transformation geometry and perspective

Viewing and Projection

Geometry: Unit 1: Transformations. Chapter 14 (In Textbook)

Computer Graphics Geometric Transformations

CS770/870 Spring 2017 Transformations

XPM 2D Transformations Week 2, Lecture 3

Given ABC with A(-1, 1), B(2, 4), and C(4, 1). Translate ABC left 4 units and up 1 unit. a) Vertex matrix: b) Algebraic (arrow) rule:

Geometry. Topic 1 Transformations and Congruence

3D Modeling using multiple images Exam January 2008

Lecture 5 2D Transformation

11.1 Rigid Motions. Symmetry

CS612 - Algorithms in Bioinformatics

CSE528 Computer Graphics: Theory, Algorithms, and Applications

GEOMETRIC TRANSFORMATIONS AND VIEWING

Linear and Affine Transformations Coordinate Systems

XPM 2D Transformations Week 2, Lecture 3

Lecture 1: Turtle Graphics. the turtle and the crane and the swallow observe the time of their coming; Jeremiah 8:7

Coordinate transformations. 5554: Packet 8 1

CS 4620 Midterm 1. Tuesday 22 October minutes

TRANSFORMATIONS. The original figure is called the pre-image; the new (copied) picture is called the image of the transformation.

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

Practical Linear Algebra: A Geometry Toolbox

CSE328 Fundamentals of Computer Graphics

3D Geometry and Camera Calibration

Computer Vision cmput 428/615

Image warping , , Computational Photography Fall 2017, Lecture 10

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

Computer Graphics Hands-on

Computer Graphics. Coordinate Systems and Change of Frames. Based on slides by Dianna Xu, Bryn Mawr College

Name: Date: Per: WARM UP

Polynomials. Math 4800/6080 Project Course

Chapter 2: Transformations. Chapter 2 Transformations Page 1

Transformations: 2D Transforms

Visual Recognition: Image Formation

Transformation. Translation To vertically and/or horizontally a figure. Each point. Reflection. Rotation. Geometry Unit 2: Transformations

Motion Control (wheeled robots)

DRAFT: Analysis of Skew Tensegrity Prisms

Lesson 5: Definition of Rotation and Basic Properties

521466S Machine Vision Exercise #1 Camera models

2D Geometric Transformations and Matrices

Unit 1 Test Review: Transformations in the Coordinate Plane

Jorg s Graphics Lecture Notes Coordinate Spaces 1

CS452/552; EE465/505. Geometry Transformations

4. Two Dimensional Transformations

Chapter 3 - Basic Mathematics for 3D Computer Graphics

3D Computer Vision II. Reminder Projective Geometry, Transformations. Nassir Navab. October 27, 2009

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

Specifying Complex Scenes

Practical Linear Algebra: A Geometry Toolbox

Coordinate Spaces & Transformations. in InDesign CS4 CC Chapter 1

METRIC PLANE RECTIFICATION USING SYMMETRIC VANISHING POINTS

Matrices. Chapter Matrix A Mathematical Definition Matrix Dimensions and Notation

CS354 Computer Graphics Rotations and Quaternions

CS770/870 Spring 2017 Transformations

Transcription:

2D Transformations Introduction to Computer Graphics Arizona State University Gerald Farin January 31, 2006 1 Introduction When you see computer graphics images moving, spinning, or changing shape, you are seeing an implementation of 2D or 3D transformations. Let s focus on 2D here; once you understand 2D, 3D is simple! 2D transformations can be posed as the following problem. Given: v in the [e 1, e 2 ]-coordinate system, where v = v 1 e 1 + v 2 e 2. Find: ˆv in the [a 1, a 2 ]-coordinate system, where ˆv = ˆv 1 a 1 + ˆv 2 a 2. The geometry of this problem is illustrated in Figure 1. Another name for a 2D transformation is a 2D linear map. The purpose of this write-up is to define 2D linear maps. [ ] [ ] a11 a12 Notation: the elements of a 1 = and a 2 =. a 21 To define the 2D transformation that takes v to ˆv, notice that in addition we want: e 1 a 1 and e 2 a 2. (1) This mapping will be defined as a 2 2 matrix, and it is easy to see that [ ] [ ] [ ] [ ] [ ] [ ] a11 a11 a = 12 1 a12 a11 a and = 12 0 a 21 a 21 a 22 0 a 22 a 21 a 22 1 A short-hand way to write these maps: a 22 a 1 = [a 1, a 2 ]e 1 and a 2 = [a 1, a 2 ]e 2. 1

a 2 e 2 v^ v a 1 e 1 Figure 1: Elements defining a linear map: [e 1, e 2 ] [a 1, a 2 ]. We ll write matrices in terms of their column vectors frequently during this course. Therefore, the vector v is mapped to ˆv by [ ] a11 a ˆv = 12 v a 21 a 22 = [a 1, a 2 ]v = Av The matrix A is called a linear map. Linear maps operate on vectors. (However, you will see them applied to points which are bound to a coordinate origin.) (2) 2

2 Determinants and Area Vectors [e 1, e 2 ] define a parallelogram (unit square) with area one. Vectors [a 1, a 2 ] define a parallelogram with area A = a 11 a 12 a 21 a 22 = a 11a 22 a 12 a 21, where A is called the determinant of matrix A. In other words, A maps the unit square to a parallelogram of area A. A = 1: no area change 0 < A < 1: shrink A > 1: expand A < 0: change orientation Handy relation: AB = A B. 3 2D Linear Maps All linear maps are composed of the following basic maps: scale, rotate, shear, projection. [ ] s 0 1. Scale uniformly: ˆv = v. See Figure 2. A = s 0 s 2. [ ] s1 0 2. Scale non-uniformly: ˆv = v. See Figure 3. A = s 0 s 1 s 2. 2 Reflections: Here are some examples of reflection matrices. A reflection will have A = 1 1. Reflections about the e 1 -axis: ˆv = [ ] 1 0 v. See Figure 4. A = 1. 0 1 3

[ ] 1/2 0 Figure 2: Uniform scale:ˆv = v. 0 1/2 Figure 3: Non-uniform scale: ˆv = [ ] 1/2 0 v. 0 3/2 4

[ ] 1 0 Figure 4: Reflection about the e 1 -axis ˆv = v. 0 1 2. Reflection about the line x 1 = x 2 : ˆv = 1. Rotation: A rotation of α is achieved by [ cos(α ˆv = ) sin(α ] ) sin(α ) cos(α v. ) [ ] 0 1 v. See Figure 5. A = 1 0 Rotations of positive degrees (α > 0) result in a counterclockwise rotation. A rotation does not change areas, that is, A = cos 2 (α ) + sin 2 (α ) = 1. Additionally, a rotation is a rigid body motion because the shape of an object is not changed by a rotation. Rotate 45 : ˆv = Shear: [ cos(45 ) sin(45 ) sin(45 ) cos(45 ) We can shear in either or both axes. 5 ] v. See Figure 6.

Figure 5: Reflection about the line x 1 = x 2 : ˆv = [ ] 0 1 v. 1 0 [ ] 1 0.5 Shear in the e 1 direction ˆv = v. See Figure 7. A = 1. (Notice 0 1 that the parallelogram maintains a base and height of one!) Projections: All vectors are projected onto a projection line. The angle of incidence with the projection line characterizes the projection, as illustrated in Figure 8, and enumerate below. 1. Parallel: All vectors have the same angle of incidence with the projection line. (a) Orthographic - angle of incidence is ninety-degrees to the projection line. [ ] 1 0 A = 0 0 (b) Oblique - arbitrary angle to the projection line [ ] 1 0 A = 1 0 6

Figure 6: Rotate 45 : ˆv = [ cos(45 ) sin(45 ] ) sin(45 ) cos(45 v. ) 2. General projections do not necessarily project all vectors with the same angle of incidence with the projection line. The general form: A = [ a 1 ca 1 ]. The columns are linearly dependent. The number of linearly independent columns is the rank of a matrix. Here: rank equals one. The determinant of a projection matrix: A = 0 since our unit square is squished to a line. 4 Properties of Linear Maps A linear map, ˆv = Av, Maps vectors vectors Preserves linear combinations of vectors. Suppose we have w = αu + βv 7

Figure 7: Shear in the e 1 direction ˆv = [ ] 1 0.5 v. 0 1 Apply the linear map: ˆv = Av û = Au ŵ = Aw And the relationship still holds: ŵ = αû + βˆv 5 Matrix Multiplication Matrix operations are not commutative: AB BA in general. For example, rotate reflect reflect rotate. See Figure 9. However, rotations in 2D do commute: R α R β = R β R α. Additionally, R α R β = R α+β. 8

Figure 8: Projections are characterized by their angle of incidence with the projection line. Left: orthographic, Middle: oblique, Right: general. 6 Affine Maps Modeling transformations include translations. This is where affine maps come in, and affine maps give us a tools for applying transformations to points. Suppose we have a point x in the [e 1, e 2 ]-system, and we would like to find the corresponding point ˆx in a system defined by a point p and [a 1, a 2 ]. This is illustrated in Figure 10. We need to apply a linear map to the vector (x o) to find the corresponding vector in the [a 1, a 2 ] system, and then translate the geometry by p, or in other words, ˆx = p + A(x o) = p + Ax Thus an affine map is a translation plus a linear map. As mentioned in Section 1, it can appear that we apply a linear map to a point, but actually we are applying the linear map to the vector formed by the point and the 9

Figure 9: Matrix operations are not commutative. Top right: rotate( 120 ) reflect(about x). This is not the same as the bottom right: reflect(about x) rotate( 120 ). 10

a 2 x^ e 2 x a 1 p o e 1 Figure 10: Affine map: defines the transformation of a point x in the [e 1, e 2 ] system to a point ˆx in the system defined by p and [a 1, a 2 ]. origin. Affine maps have the following properties. 1. A point is mapped to a point. 2. The ratio of three collinear points is preserved. For example, suppose points r, s, and x are collinear and ratio(r, x, s) = α : β. Apply an affine map to these points, resulting in points ˆr, ŝ, and ˆx, then these points are collinear and ratio(ˆr, ˆx, ŝ) = α : β. See Figure 11. 3. Parallel lines are mapped to parallel lines. Translations (along with rotations) are rigid body motions they transform the geometry without deforming it. Exercise: As practice in constructing affine maps, try creating the affine map (by defining A and p) that takes the o, [e 1, e 2 ] local coordinates to the global coordinates defined by the target box g min, g max. 11

s r^ x^ r x affine map s^ Figure 11: Affine maps preserve the ratio of three collinear points. Problem: Given points r and x, rotate x d degrees about r. This geometry is illustrated in Figure 12. This is a problem that arises frequently in computer graphics. A constructive approach is necessary as a 1 and a 2 are not given directly. One way to think about it: Translate r and x to the origin, rotate, and then translate the geometry back to its original position, or in other words, ˆx = r + A(x r) [ cos(d = r + ) sin(d ] ) sin(d ) cos(d (x r). ) Figures extracted from The Geometry Toolbox for Graphics and Modeling Gerald Farin and Dianne Hansford AK Peters, 2nd edition, 2004 12

x^ d o r x Figure 12: Problem: Rotate point x d about the point r, resulting in point ˆx. Here: d = 90. 13