Computer Graphic 2 D Transformation.

Slides:



Advertisements
Similar presentations
Computer Graphics: 2D Transformations
Advertisements

COMPUTER GRAPHICS 2D TRANSFORMATIONS.
Gursharan Singh Tatla TRANSFORMATIONS Gursharan Singh Tatla Gursharan Singh Tatla.
Computer Graphics Lecture 4 Geometry & Transformations.
Chapter 5 Geometric Transformations
CMPE 466 COMPUTER GRAPHICS
Elementary 3D Transformations - a "Graphics Engine" Transformation procedures Transformations of coordinate systems Translation Scaling Rotation.
CS 376 Introduction to Computer Graphics 02 / 09 / 2007 Instructor: Michael Eckmann.
1 CSCE 441 Computer Graphics: 2D Transformations Jinxiang Chai.
2D/3D Geometric Transformations CS485/685 Computer Vision Dr. George Bebis.
Course Website: Computer Graphics 3: 2D Transformations.
Computer Graphics with OpenGL 3e
Larry F. Hodges (modified by Amos Johnson) 1 2D Transformations.
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.
Mathematical Fundamentals
COS 397 Computer Graphics Svetla Boytcheva AUBG, Spring 2013.
Geometric Transformation. So far…. We have been discussing the basic elements of geometric programming. We have discussed points, vectors and their operations.
Transformation of Graphics
Graphics Graphics Korea University kucg.korea.ac.kr Transformations 고려대학교 컴퓨터 그래픽스 연구실.
2D Transformation of Graphics
Lecture Notes: Computer Graphics.
2D Geometric Transformations
Part7: Geometric Transformations
Transformations Jehee Lee Seoul National University.
Geometric Transformations
CS 376 Introduction to Computer Graphics 02 / 16 / 2007 Instructor: Michael Eckmann.
Computer Graphics 2D Transformations. 2 of 74 Contents In today’s lecture we’ll cover the following: –Why transformations –Transformations Translation.
Computer Graphics 3D Transformations. Translation.
Two-Dimensional Geometric Transformations ch5. 참조 Subjects : Basic Transformations Homogeneous Coordinates Composite Transformations Other Transformations.
Two-Dimensional Geometric Transformations A two dimensional transformation is any operation on a point in space (x, y) that maps that point's coordinates.
Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.
Geometric Transformations
GEOMETRIC TRANFORMATIONS Presented By -Lakshmi Sahithi.
Affine Transformation. Affine Transformations In this lecture, we will continue with the discussion of the remaining affine transformations and composite.
Geometric Transformations UBI 516 Advanced Computer Graphics Aydın Öztürk
3-D Geometric Transformations
3D Geometric Transformation
II-1 Transformations Transformations are needed to: –Position objects defined relative to the origin –Build scenes based on hierarchies –Project objects.
Learning Objectives Affine transformations Affine transformations Translation Translation Rotation Rotation Scaling Scaling Reflection Reflection Shear.
Honors Geometry.  We learned how to set up a polygon / vertex matrix  We learned how to add matrices  We learned how to multiply matrices.
III- 1 III 3D Transformation Homogeneous Coordinates The three dimensional point (x, y, z) is represented by the homogeneous coordinate (x, y, z, 1) In.
Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.
1 Teaching Innovation - Entrepreneurial - Global The Centre for Technology enabled Teaching & Learning, N Y S S, India DTEL DTEL (Department for Technology.
CS 551 / 645: Introductory Computer Graphics Viewing Transforms.
CS 325 Introduction to Computer Graphics 02 / 19 / 2010 Instructor: Michael Eckmann.
Geometric Transformations Ceng 477 Introduction to Computer Graphics Computer Engineering METU.
2D Transformations What is transformations? The geometrical changes of an object from a current state to modified state. Why the transformations is needed?
CSCE 441 Computer Graphics: 2D Transformations
3D Geometry and Transformations
Instructor: Dr. Shereen Aly Taie Basic Two-Dimensional Geometric Transformation 5.2 Matrix Representations and Homogeneous Coordinates 5.3 Inverse.
Transformations University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2016 Tamara Munzner.
Forward Projection Pipeline and Transformations CENG 477 Introduction to Computer Graphics.
Computer Graphics 2D Transformations
Transforms.
Computer Graphics 3: 2D Transformations
3D Geometric Transformation
Geometric Transformations Hearn & Baker Chapter 5
2D Geometric Transformations
Computer Graphics Transformations.
Computer Graphics 3: 2D Transformations
3D Transformation.
3D Geometric Transformations
Chapter 5 2-D Transformations.
Computer Graphics Transformations.
Computer Graphics Transformations
Line and Character Attributes 2-D Transformation
© 2008, Fayyaz A. Afsar, DCIS, PIEAS.
Chapter IV Spaces and Transforms
TWO DIMENSIONAL TRANSFORMATION
Presentation transcript:

Computer Graphic 2 D Transformation

Outline 1. Why transformations ? 2. Basic 2D Transformations Translation Scaling Rotation 3. Homogeneous Coordinate system 4. Composite Transformations 5. Reflection and Shearing

Why transformations ? In graphics, once we have an object described, transformations are used to move that object, scale it and rotate it

Basic 2D Transformations Translation Simply moves an object from one position to another Note: House shifts position relative to origin y x 1 2 3 4 5 6 7 8 9 10

2D Translation Moving a polygon from position (a) to position (b) with the translation vector (-5, 10), i.e. x y 5 10 15 20 x y 5 10 15 20 p3(15,10) P1(10,5) P2(20,5) (a) (b)

Basic 2D Transformations Scaling Scalar multiplies all coordinates WATCH OUT: Objects grow and move! Note: House shifts position relative to origin y x 1 2 3 4 5 6 7 8 9 10

Example: Non- Uniform Scaling (b) Non-uniform scaling

Basic 2D Transformations Rotation sin(a+b) = sin(a)cos(b) + sin(b)cos(a)  cos(a+b) = cos(a)cos(b) - sin(a)sin(b)  sin(a+b) = sin(a)cos(b) + sin(b)cos(a)  cos(a+b) = cos(a)cos(b) - sin(a)sin(b)  Similarly,

Rotation

Homogenous 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 Homogenous 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!

Example: Rotate a polygonal object defined by vertices A(0,0),B(1,0) ,C(1,1) and D(0,1) by 45 about the origin

Points are always rotated about the origin Rotation 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

2D Transformations in Homogenous Notation Rotation Scaling Translation

Inverse Transformations Inverse of Rotation Inverse of Scaling Inverse of Translation

Example Consider the line with endpoints (10, 10) and (30, 25). Translate it by tx = -20, ty = -10 and then rotate it by θ = 90º. x y (10, 10) (30, 25) Right-to-left

Solution x y (10, 10) (30, 25)

Solution (continue) Point (10, 10) Point (30, 25) y x (30, 25) (0, -10) (-15, 10) Point (10, 10) Point (30, 25)

Exercises Consider the following object: Apply a rotation by 145º then scale it by Sx=2 and Sy=1.5 and then translate it by tx=20 and ty=-30. Scale it by Sx=½ and Sy=2 and then rotate it by 30º. Apply a rotation by 90º and then another rotation by 45º. Apply a rotation by 135º. x y 10 25 45

Scaling about a Reference Point If the center of the object is not at the origin, in this case we should consider a scaling as a composite transformation which involves the following steps. Translation of the reference (xc,yc) to the origin Scale the object by scale factor by (Sx,Sy) Translation of the reference point back to its original position

(a) Original position of object and fixed point (xc, yc)T (a) Original position of object and fixed point (b) Translate object so that fixed point (xr, yr) is at origin (xc, yc)T (c) Scale object with respect to origin (d) Translate object so that fixed point is returned to position (xr, yr)T 22

Combining the Transformation The three transformation matrices are combined as follows

Example1: Consider a triangle having a vertices at A(0,0), B(5,1), and C(3,4) scale this triangle using scaling factors Sx=2 and Sy=1 about a) the origin b) about the reference point (2,3) a) At origin ( xr=0, yr=0)

b) Scaling about the reference point (2,3) : Here, the transformation matrix

Rotation about an Arbitrary Point Rotation about an arbitrary point is composite transformation . This operation involve s three basic transformations: Translation of the object center (xc,yc) to the origin Rotation of the object about the origin by angle θ in.say, the anticlockwise direction Translation of the rotated object back to its original position

1 2 3 4

Example: Consider a triangle having a vertices at A(0,0), B(5,1), and C(3,4) scale this triangle. Rotate the triangle by 90 about a) the origin b) about the reference point (2,3) Solution: a) about the origin The transformation matrix for rotation about the origin :

b) Rotation about point (2,3 )

Exercises Consider the following object: Apply a rotation by 60° on the Pivot Point (-10, 10) and display it. Apply a rotation by 30° on the Pivot Point (45, 10) and display it. Apply a rotation by 270° on the Pivot Point (10, 0) and then translate it by tx = -20 and ty = 5. Display the final result. x y 10 25 45

Reflection About the x axis About the y axis y x y x Reflection of an object about the x axis x y About the y axis x y Reflection of an object about the y axis

Same as a rotation with 180º Reflection Relative to the coordinate origin Same as a rotation with 180º x y With respect to the line y = x x y y = x

Reflection about x=-y line : the x and y coordinates are interchanged and their values are negated after reflection Original position y y = -x 3 1 2 Reflected position 1’ 3’ 2’ x

Reflection about any arbitrary line: y=mx+b This kind of reflection can be implemented by a sequence of the following steps: Translate the line, along the y-axis so that it pass the origin Rotate through an angle θ =tan-1(m) in clockwise so that the line is aligned with x-axis Reflect the object about x-axis Perform inverse Rotation and Translation

Example: Consider a triangle whose vertices are (2 2), (4 2) and (4 4) Example: Consider a triangle whose vertices are (2 2), (4 2) and (4 4). Find the concatenated transformation matrix and the transformed vertices for rotation of 90 about the origin followed by reflection through the line y = -x. Comment on the sequence of transformations.

Ex: Reflect triangle (2,4),(4,6),(2,6) about line y=0.5(x+4) Translate (0, -2) so that the line passes through the origin b ϴ Rotate the line about the x axis by -θo

Reflect object about the x axis Rotate back the line by θo

5. Translate back (0,2)

The final position of line after reflection about the line is

Shearing about the origin y y y (1, 3) (1, 2) (1, 1) (2, 1) (3, 1) (0, 1) (0, 1) x x x (0, 0) (1, 0) (0, 0) (1, 0) (0, 0) (a) (b) (c) SHy=2 SHx=2 41

Shearing about the a reference point ( xr,yr)

Shear Example