Section III: TRANSFORMATIONS

Similar documents
2D TRANSFORMATIONS AND MATRICES

UNIT 2 2D TRANSFORMATIONS

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

Homogeneous Coordinates and Transformations of the Plane

Graphics and Interaction Transformation geometry and homogeneous coordinates

COMP30019 Graphics and Interaction Transformation geometry and homogeneous coordinates

2D and 3D Coordinate Systems and Transformations

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

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

Game Engineering: 2D

Unit 3 Transformations and Clipping

Vector Algebra Transformations. Lecture 4

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

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

Part 3: 2D Transformation

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

Chapter 1. Linear Equations and Straight Lines. 2 of 71. Copyright 2014, 2010, 2007 Pearson Education, Inc.

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

Computer Graphics: Geometric Transformations

Computer Graphics Hands-on

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

Computer Graphics Geometric Transformations

(Refer Slide Time: 00:04:20)

Transforms. COMP 575/770 Spring 2013

Linear and Affine Transformations Coordinate Systems


AH Matrices.notebook November 28, 2016

Partial Derivatives. Partial Derivatives. Partial Derivatives. Partial Derivatives. Partial Derivatives. Partial Derivatives

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

If three points A (h, 0), P (a, b) and B (0, k) lie on a line, show that: a b 1.

Overview. By end of the week:

GEOMETRIC TRANSFORMATIONS AND VIEWING

1 Affine and Projective Coordinate Notation

Transformations Week 9, Lecture 18

Computer Graphics: Two Dimensional Viewing

521493S Computer Graphics Exercise 1 (Chapters 1-3)

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

Isometries. 1 Identifying Isometries

Today s Topics. 3. Transformations in 2D. 4. Coordinate-free geometry. 5. 3D Objects (curves & surfaces) 6. Transformations in 3D

Homework 5: Transformations in geometry

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

window World space (Object space)

Transformations: 2D Transforms

2D and 3D Transformations AUI Course Denbigh Starkey

Three-Dimensional Viewing Hearn & Baker Chapter 7

Computer Graphics Hands-on

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

CS770/870 Spring 2017 Transformations

MODULE - 7. Subject: Computer Science. Module: Other 2D Transformations. Module No: CS/CGV/7

CT5510: Computer Graphics. Transformation BOCHANG MOON

DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI

Homework 5: Transformations in geometry

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

Computer Science 336 Fall 2017 Homework 2

Affine Transformation. Edith Law & Mike Terry

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

Basic Elements. Geometry is the study of the relationships among objects in an n-dimensional space

Geometric Transformations Sequence

2D Object Definition (1/3)

COMP3421. Vector geometry, Clipping

Lecture 5 2D Transformation

Basics of Computational Geometry

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

Perspective Mappings. Contents

Transformations. Examples of transformations: shear. scaling

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

Specifying Complex Scenes

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

Geometric transformations in 3D and coordinate frames. Computer Graphics CSE 167 Lecture 3

Matrices. Chapter Matrix A Mathematical Definition Matrix Dimensions and Notation

Camera Model and Calibration

Monday, 12 November 12. Matrices


Projection Lecture Series

Quaternions and Dual Coupled Orthogonal Rotations in Four-Space

Modeling Transformations

2D Geometric Transformations and Matrices

Two Dimensional Viewing

Rectangular Coordinates in Space

Computer Graphics 7: Viewing in 3-D

Shadows in Computer Graphics

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

CSE528 Computer Graphics: Theory, Algorithms, and Applications

Animated Cartoons by Computer Using Ellipsoids

CARTESIAN OVOIDS. A. Cartesian Ovoids in the case n o < n i

Coordinate transformations. 5554: Packet 8 1

Drill Exercise - 1. Drill Exercise - 2. Drill Exercise - 3

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

MATRIX REVIEW PROBLEMS: Our matrix test will be on Friday May 23rd. Here are some problems to help you review.

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

Coordinate Transformations & Homogeneous Coordinates

GRAFIKA KOMPUTER. ~ M. Ali Fauzi

3D Transformations World Window to Viewport Transformation Week 2, Lecture 4

Multiple View Geometry in Computer Vision

Lecture 9: Transformations. CITS3003 Graphics & Animation

Module 4F12: Computer Vision and Robotics Solutions to Examples Paper 2

MET71 COMPUTER AIDED DESIGN

Graphics Pipeline 2D Geometric Transformations

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

Transcription:

Section III: TRANSFORMATIONS in 2-D

2D TRANSFORMATIONS AND MATRICES Representation of Points: 2 x 1 matrix: X Y General Problem: [B] = [T] [A] [T] represents a generic operator to be applied to the points in A. T is the geometric transformation matrix. If A & T are known, the transformed points are obtained by calculating B.

General Transformation of 2D points: x' y' a b c d x y x' y' T x y T a c b d x' ax cy x' ax cy y' bx dy y' bx dy Solid body transformations the above equation is valid for all set of points and lines of the object being transformed.

Special cases of 2D Transformations: 1) T = identity matrix: a=d=1, b=c=0 => x'=x, y'=y 2) Scaling & Reflections: b=0, c=0 => x' = a.x, y' = d.y; This is scaling by a in x, d in y. If, a = d > 1, we have enlargement; If, 0 < a = d < 1, we have compression; If a = d, we have uniform scaling, else non-uniform scaling. Scale matrix: let S x = a, S y = d: S S x 0 0 S y

Example of Scaling S x = 3 S y = 2 Y 6 5 4 3 2 1 2 2 1 3 3 1 6 2 9 22 0 1 2 3 4 5 6 7 8 9 X What if S x and/ or S y < 0 (are negative)? Get reflections through an axis or plane. Only diagonal terms are involved in scaling and reflections. Note : House shifts position relative to origin i

More examples of Scaling and reflection Reflection (about the Y-axis) x = x x Non-uniform scaling x x = x + ay

Special cases of Reflections ( T = -1) Matrix T 1 0 0 1 0 1 1 0 0 1 1 0 0 1 1 0 Reflection about Y=0 Axis (or X-axis) X=0 Axis (or Y-axis) Y = X Axis Y = -X Axis

Off diagonal terms are involved in SHEARING; a = d = 1; let, c = 0, b = 2 x' = x y' = 2x + y ; a b x' y' c d ax bx x y cy dy x' y' y' depends linearly on x ; This effect is called shear. Similarly for b=0, c not equal to zero. The Similarly for b=0, c not equal to zero. The shear in this case is proportional to y-coordinate.

X' Y' ROTATION xcos xsin ysin ycos In matrix form, this is : cos( ) - sin( ) sin( ) cos( ) Y 5 4 3 T 0 2 1 = 30 1 2 3 4 5 X Positive Rotations: counter clockwise about the origin For rotations, T = 1 and [T] T = [T] -1. Rotation matrices are orthogonal.

Special cases of Rotations (in degrees) Matrix T 0 1 90 1 0 1 0 180 0 1 0 1 270 or -90 1 0 1 0 360 or 0 0 1

Example - Transformation of a Unit Square Y b+d Y d (1, 1) x b c a a+c c a a+c x 0 0 0 0 1 1 0 1 S d b c a b a d c b a S S' 1 0 1 1 d c d b c a d c Area of the unit square after transformation = ad - bc = T. ad bc T. Extend this idea for any arbitrary area.

Translations Y 6 5 t x = 5 4 t 3 y = 1 2 1 2 3 2 2 0 7 3 1 2 3 4 5 6 7 8 9 X

Translations B = A + T d, where T d = [t x t y ] T Where else are translations introduced? 1) Rotations - when objects are not centered at the origin. 2) Scaling - when objects/lines are not centered at the origin i - if line intersects t the origin, no translation. Origin is invariant to Scaling, reflection and Shear not translation.

Note: we cannot directly represent translations as matrix multiplication, as we can for: SCALING ROTATION Can we represent translations in our general transformation matrix? Yes, by using homogeneous coordinates

HOMOGENEOUS COORDINATES x t c a x' y x t d b t c a y x y x * ' Use a 3 x 3 matrix: w y w y y 1 0 0 ' We have: We have: x' = ax + cy + t x y' = bx + cy + t y = bx + cy + t y Each point is now represented by a triplet: Each point is now represented by a triplet: (x, y, w). (x/w, y/w) are called the Cartesian coordinates of the homogeneous points. coordinates of the homogeneous points.

Interpretation of Homogeneous Coordinates W P h (x, y, w) 1 P 2d (x/w, y/w, 1) x Y

Two homogeneous coordinates (x 1, y 1, w 1 ) & (x 2, y 2, w 2 ) may represent the same point, iff they are multiples of one another: say, (1,2,3) & (3,6,9). There is no unique homogeneous representation of a point. All triples of the form (t.x, t.y, t.w) form a line in x,y,w space. Cartesian coordinates are just the plane w=1 in this space. W=0, are the points at infinity

General Purpose 2D transformations in homogeneous coordinate representation T a b p c m Parameters involved in scaling, rotation, reflection and shear are: a, b, c, d If B = T.A, then d n q s If B = A.T, then Translation Translation parameters: parameters: What about (p, q) (m, n) S?

COMPOSITE TRANSFORMATIONS If we want to apply a series of transformations T 1, T 2, T 3 to a set of points, We can do it in two ways: 1) We can calculate p'=t 1 *p, p''= T 2 *p', p'''=t 3 *p'' 2) Calculate T= T 1 *T 2 *T 3, then p'''= T*p. Method 2, saves large number of additions and multiplications (computational time) needsapproximately1/3ofasmanyoperations. Therefore, we concatenate or compose the matrices into one final transformation matrix, and then apply that to the points.

Translations: 1 0 ( tx tx ) 1 2 Translate the points by tx 0 1 ty ty 1, ty 1, then by tx 2, ty 2 : ( ) 1 2 0 0 1 Scaling: Similar to translations Rotations: Rotate by 1, then by 2 : (i) stick the ( 1 + 2 )infor, or (ii) calculate l T 1 for 1, then T 2 for 2 & multiply them. Exercise: Both gives the same result work it out

Rotation about an arbitrary point P in space As we mentioned before, rotations are applied about the origin. So to rotate about any arbitrary point P in space, translate so that P coincides with the origin, then rotate, then translate back. Stepsare: Translate by (-P x, -P y ) y Rotate Translate by (P x, P y )

Rotation about an arbitrary point P in space P 1 House at P 1 Rotation by P 1 Translation of Translation P 1 to Origin back to P 1

Rotation about an arbitrary point P in space T = T 1 (-P x, -P y ) * T 2 () * T 3 (P x, P y )

Scaling about an arbitrary point in Space Again, Translate P to the origin Scale Translate P back T = T 1 1( (P x, P y )* T 2 2( (S x, S y )*T 3 3( (-P x, -P y ) T Sx 0 { Px *(1 Sx )} 0 Sy { Py *(1 Sy )} 0 0 1

Reflection through an arbitrary line Steps: Translate line to the origin Rotation about the origin Reflection matrix Reverse the rotation Translate line back T T R T R T T GenRfl r rfl r 1

Commutivity of Transformations If we scale, then translate to the origin, and then translate back, is that equivalent to translate to origin, scale, translate back? When is the order of matrix multiplication unimportant? When does T 1 *T 2 =T 2 *T 1? Cases where T 1 * T 2 = T 2 * T 1 : T 1 T 2 translation translation scale rotation scale(uniform) scale rotation rotation

Order: R-G-B Scale, translate Translate, scale Rotate, differential scale Differential scale, rotate

COORDINATE SYSTEMS Screen Coordinates: The coordinate system used to address the screen (device coordinates) World Coordinates: A user-defined application specific coordinate system having its own units of measure, axis, origin, etc. Window: The rectangular region of the world that is visible. Viewport: The rectangular region of the screen space that is used to display the window.

Y Window V Viewport2 Viewport1 World X Screen U

WINDOW TO VIEWPORT TRANSFORMATION Purpose is to find the transformation matrix that maps the window in world coordinates to the viewport in screen coordinates. Window: (x, y space) denoted by: x min,y min, x max,y max Viewport: (u v space) denoted by: Viewport: (u, v space) denoted by: u min, v min, u max, v max

The overall transformation: Translate the window to the origin Scale it to the size of the viewport Translate it to the viewport location M S S x y M WV ( U ( V WV T( Umin, Vmin)* S( Sx, Sy)* T( xmin, ymin); max max U V min min )/( x )/( y max max y x min min ); ); Sx 0 ( xmin* Sx Umin) 0 S y ( ymin* Sy Vmin) 0 0 1

Y Window Viewport Transformation (X max,y max ) Y (X min, Y min) ) X Window in World Coordinates V U Window Scaled to size to Viewport V X Window translated to origin (U min,v min ) Maximum Screen Coordinates U Viewport Translated ated to final position

Exercise -Transformations of Parallel Lines Consider two parallel lines: (i) A[X 1, Y 1 ] to B[X 2, Y 2 ] and (ii) C[X 3, Y 3 ] to B[X 4, Y 4 ]. Slope of the lines: m Y Y Y Y 2 1 4 X X X X 2 1 4 3 3 Solve the problem: If the lines are transformed by a matrix: T a b c d The slope of the transformed lines is: m' b dm a cm