UNIT 2 2D TRANSFORMATIONS

Similar documents
2D TRANSFORMATIONS AND MATRICES

Section III: TRANSFORMATIONS

DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI

Computer Graphics: Geometric Transformations

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

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

Unit 3 Transformations and Clipping

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

Modeling Transformations

Part 3: 2D Transformation

Homogeneous Coordinates and Transformations of the Plane

2D and 3D Transformations AUI Course Denbigh Starkey

What and Why Transformations?

Coordinate transformations. 5554: Packet 8 1

Graphics and Interaction Transformation geometry and homogeneous coordinates

COMP30019 Graphics and Interaction Transformation geometry and homogeneous coordinates

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

Two Dimensional Viewing

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

Game Engineering: 2D

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

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

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

Transformations: 2D Transforms

CT5510: Computer Graphics. Transformation BOCHANG MOON

2D and 3D Coordinate Systems and Transformations

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

MET71 COMPUTER AIDED DESIGN

1 Affine and Projective Coordinate Notation

Computer Graphics Geometric Transformations

Computer Graphics 7: Viewing in 3-D

Transforms. COMP 575/770 Spring 2013

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

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

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

(Refer Slide Time: 00:04:20)

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

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

3D Computer Graphics. Jared Kirschner. November 8, 2010

AH Matrices.notebook November 28, 2016

2D Object Definition (1/3)

GEOMETRIC TRANSFORMATIONS AND VIEWING

Computer Graphics Hands-on

CSE528 Computer Graphics: Theory, Algorithms, and Applications

Vector Algebra Transformations. Lecture 4

Chapter 5. Transforming Shapes

Computer Graphics: Two Dimensional Viewing

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

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

Affine Transformation. Edith Law & Mike Terry

Transformations Week 9, Lecture 18

Chapter 5. Projections and Rendering

CS 4204 Computer Graphics

2D/3D Geometric Transformations and Scene Graphs

THE VIEWING TRANSFORMATION

CSE328 Fundamentals of Computer Graphics

Homework 5: Transformations in geometry

Section 12.1 Translations and Rotations

Overview. By end of the week:

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

Therefore, after becoming familiar with the Matrix Method, you will be able to solve a system of two linear equations in four different ways.

Rectangular Coordinates in Space

GEOMETRIC OBJECTS AND TRANSFORMATIONS I

Linear algebra deals with matrixes: two-dimensional arrays of values. Here s a matrix: [ x + 5y + 7z 9x + 3y + 11z

CALCULATING TRANSFORMATIONS OF KINEMATIC CHAINS USING HOMOGENEOUS COORDINATES

Specifying Complex Scenes

Matrices. Chapter Matrix A Mathematical Definition Matrix Dimensions and Notation

COMP30019 Graphics and Interaction Three-dimensional transformation geometry and perspective

Models and The Viewing Pipeline. Jian Huang CS456

INTRODUCTION TO COMPUTER GRAPHICS. It looks like a matrix Sort of. Viewing III. Projection in Practice. Bin Sheng 10/11/ / 52

Cs602-computer graphics MCQS MIDTERM EXAMINATION SOLVED BY ~ LIBRIANSMINE ~

S56 (5.3) Higher Straight Line.notebook June 22, 2015

3D Polygon Rendering. Many applications use rendering of 3D polygons with direct illumination

Three-Dimensional Viewing Hearn & Baker Chapter 7

GRAFIKA KOMPUTER. ~ M. Ali Fauzi

CSC 305 The Graphics Pipeline-1

COMP3421. Vector geometry, Clipping

CS602 MCQ,s for midterm paper with reference solved by Shahid

Computer Vision cmput 428/615

2009 GCSE Maths Tutor All Rights Reserved

Representing 2D Transformations as Matrices

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

Lecture 9: Transformations. CITS3003 Graphics & Animation

Viewing with Computers (OpenGL)

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

Chapter 5. Transformations of Objects

N-Views (1) Homographies and Projection

Computer Aided Design (CAD)

CS452/552; EE465/505. Geometry Transformations


Motion Control (wheeled robots)

Lecture 5 2D Transformation

Linear and Affine Transformations Coordinate Systems

Chapter 2 - Basic Mathematics for 3D Computer Graphics

Geometry Vocabulary. acute angle-an angle measuring less than 90 degrees

Lecture 3 Sections 2.2, 4.4. Mon, Aug 31, 2009

Overview of Transformations (18 marks) In many applications, changes in orientations, size, and shape are accomplished with

Let a line l and a point P not lying on it be given. By using properties of a transversal and parallel lines, a line which passes through the point P

Computer Graphics Hands-on

PRACTICAL GEOMETRY SYMMETRY AND VISUALISING SOLID SHAPES

Transcription:

UNIT 2 2D TRANSFORMATIONS Introduction With the procedures for displaying output primitives and their attributes, we can create variety of pictures and graphs. In many applications, there is also a need for altering or manipulating displays. Design applications and facility layouts are created by arranging the orientations and sizes of the component parts of the scene. And animations are produced by moving the "camera" or the objects in a scene along animation paths. Changes in orientation, size, and shape are accomplished with geometric transformations that alter the coordinate descriptions of objects. The basic geometric transformations are translation, rotation, and scaling. Other transformations that are often applied to objects include reflection and shear. 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 Solid body (size and shape does not change) transformations - above equation is valid for all set of points and lines of the object being transformed. 1

Special cases of 2D transforms T= identity matrix, a=d=1, b=c=0 => x'=x, y'=y Scaling A scaling transformation alters the size of an object 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 or differential scaling. Scale matrix: let Sx =a, Sy =d Sx 0 0 Sy Example of Scaling 2

If Sx and/ or Sy< 0 are negative reflections are obtained through an axis or plane. Only diagonal terms involved in scaling and reflections. Reflection A transformation that produces a mirror image of an object - Shearing - Shear transformation distorts the shape of the object. - This effect causes the object to be pushed to one side as it it was constructed of layers that slide on top of each other. - Off diagonal terms are involved in Shearing. 3

a = d = 1 let, c = 0, b = 2 x' = x y' = 2x+ y y' depends linearly on x; This effect is called shear. Similarly for b=0, c not equal to zero. The shear in this case is proportional to y- coordinate. Rotation A two-dimensional rotation is applied to an object by repositioning it along a circular path in the xy plane. x' = xcos(θ) - ysin(θ) y' = xsin(θ) + ycos(θ) In matrix form, this is : cos(θ) -sin(θ) sin(θ) cos(θ) 4

Positive Rotations can be achieved if rotation is in counter clockwise about the origin Negative rotations can be achieved if rotation is in clockwise about the origin For rotations, det T = 1 and T T = T -1, Rotation matrices are orthogonal. Transformation of a unit square Take a square with coordinates (0,0),(1,0),(1,1),(0,1) Then the matrix will be represented as The transformation on the matrix S with a Transformation matrix T = 5

S = S * T The unit square after applying transformation is shown in fig. as is changed to rhombus structure. Area of the unit square after transformation = ad bc = T This can be extended to any arbitrary area of any polygon. Translation 6

The translations are introduced with 1) Rotations -when object not centered at the origin. 2) Scaling -when objects / lines not centered at the origin. If line intersects the origin, no translation we cannot directly represent translations as matrix multiplication, as we can rotations and scalings. we can represent translations in our general transformation matrix by using homogeneous coordinates. 7

HOMOGENEOUS COORDINATES Each point is now represented by a triple: (x, y, W) ( x/w, y/w) are called the Cartesian coordinates of the homogeneous points. 8

Interpretation of homogeneous coordinates Triples of coordinates typically represent points in 3D space but here we are using them to represent points in 2D space. If we take all triples representing the same point that is all triples of the form (tx,ty,tw) with w 0, we get a line in 3D space. Thus each homogeneous point represents a line in 3D space. If we homogenize the point (divide by w), we get a point of the form(x,y,1). Thus the homogenized points form the plane defined by the equation w=1 in (x,y,w) space. The following fig. shows this relationship. Fig. The XYW homogeneous coordinate space with the w=1 plane and point P(X,Y,W) projected onto the W=1 plane. Two homogeneous coordinates (x1, y1, w1) & (x2,y2, w2) may represent the same point, iff they are multiples of one another: (1,2,3) & (3,6,9). There is no unique homogeneous representation of a point. All triples of the form (tx, ty, tw) 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 9

General purpose 2D transformations in homogeneous coordinate representation Parameters involved in scaling, rotation, reflection and shear are a, b, c, d If B = T.A then Translation parameters: ( p, q ) If B = A. T then Translation parameters: ( m, n ) COMPOSITION OF TRANSFORMATIONS If we want to apply a series of transformations T1, T2, T3 to a set of points, We can do it 2 ways: 1) We can calculate p'=t1*p, p'' = T2*p', p'''=t3*p'' 2) Calculate T= T1*T2*T3, then p'''= T*p. Method 2, saves large number of adds and multiplies. Approximately 1/3 as many operations. Therefore, we concatenate or compose the matrices into one final transformation matrix that we apply to the points. Translation Translate the points by tx1, ty1, then by tx2, ty2: 10

Scaling Scale the point by sx1,sy1 then by sx2,sy2. Rotation Rotate by θ1, then by θ2, 1) stick the (θ1+ θ2) in for θ, or 2) calculate T1 for θ1, then T2 for θ2 & multiply them. Gives same result Rotation about an arbitrary point P in space As we mentioned before, rotations are about the origin. So to rotate about a point P in space, translate so that P coincides with the origin, then rotate, then translate back. Steps are Translate by (-Px, -Py) Rotate Translate by (Px, Py) 11

T = T1(Px,Py) * T2(θ) * T3(-Px, -Py) Scaling about an arbitrary point in Space Again, Translate P to the origin Scale Translate P back T = T1(Px,Py) * T2(sx, sy)* T3(-Px, -Py) Reflection through an arbitrary line Reflections about any line y = mx + b in the xy plane can be accomplished with a combination of translate rotate-reflect transformations. In general, we first translate the Line so that it passes through the origin. Then we can rotate the line onto one of the coordinate axes and reflect about that axis. Finally, we restore the line to its original position with the inverse rotation and translation transformations. Steps: Translate line to the origin Rotation about the origin Reflection matrix Reverse the rotation Translate line back 12

Commutivity of Transformations Matrix multiplication is associative. For any three matrices, A, B, and C, the matrix product A. B. C can be performed by first multiplying A and B or by first multiplying B and C: A. B.C = (A.B).C = A. (B. C) Therefore, we can evaluate matrix products using either a left-to-right or a right to left associative grouping. On the other hand, transformation products may not be commutative: The matrix product A. B is not equal to B. A, in general. This means that if we want to translate and rotate an object, we must be careful about the order in which the composite matrix is evaluated. For some special cases, such as a sequence of transformations all of the same kind, the multiplication of transformation matrices is commutative. The following table shows the cases where T1 * T2 = T2 * T1 T1 translation scale rotation scale(uniform) T2 translation scale rotation rotation 13

Example: Order: R G B Fig.a fig.b In Figure a, the object is first scaled and then translated. In figure b, the object is first translated and then scaled. As seen in figs. both are not identical. Fig.c Fig.d In Figure c, the object is first rotated and then differential scaling is applied. In figure d, the object is first differentially scaled and then rotated. As seen in figs. both are not identical. In general, multiplication of transformation matrices is not commutative. 14

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. WINDOW TO VIEWPORT TRANSFORMATION The purpose is to find the transformation matrix that maps the window in world coordinates to the viewport in screen coordinates. Viewport: (u, v space) denoted by: u min, v min, u max, v max Window: (x, y space) denoted by: x min, y min, x max, y max 15

The overall transformation: Translate the window to the origin Scale it to the size of the viewport Translate it to the viewport location M WV -> Transformation matrix to convert Window to view port. Summary: The basic geometric transformations are translation, rotation, and scaling. Translation moves an object in a straight-line path from one position to another. Rotation moves an object from one position to another in a circular path around a specified pivot point (rotation point). Scaling changes the dimensions of an object relative to a specified fixed point. We can express two-dimensional geometric transformations as 3 by 3 matrix operators, so that sequences of transformations can be concatenated into a single composite matrix. This is an efficient formulation, since it allows us to reduce computations by applying the composite matrix to the initial coordinate positions of an object to obtain the final transformed positions. 16

To do this, we also need to express two-dimensional coordinate positions as threeelement column or row matrices. We choose a column-matrix representation for coordinate points because this is the standard mathematical convention and because many graphics packages also follow this convention. For twodimensional transformations, coordinate positions are: then represented with three-element homogeneous coordinates with the third (homogeneous) coordinate assigned the value. I. Composite transformations are formed as multiplications of any combination of translation, rotation, and scaling matrices. Other transformations include reflections and shears. Reflections are transformations that rotate an object 180" about a reflection axis. This produces a mirror image of the object with respect to that axis. When the reflection axis is perpendicular to the xy plane, the reflection is obtained as a rotation n the xy plane. When the reflection axis is in the xy plane, the reflection is obtained as a rotation in a plane that is perpendicular to the xy plane. Shear transformations distort the shape of an object by shifting x or y coordinate values by an amount to the coordinate distance from a shear reference line 2 Marks 1. What is Transformation? Transformation is the process of introducing changes in the shape size and orientation of the object using scaling rotation reflection shearing & translation etc. 2. Write short notes on active and passive transformations? In the active transformation the points x and x represent different coordinates of the same coordinate system. Here all the points are acted upon by the same transformation and hence the shape of the object is not distorted. In a passive transformation the points x and x represent same points in the space but in a different coordinate system. Here the change in the coordinates is merely due to the change in the type of the user coordinate system. 3. What is translation? Translation is the process of changing the position of an object in a straight-line path from one coordinate location to another. Every point (x, y) in the object must under go a displacement to (x,y ). the transformation is: x = x + tx ; y = y + ty 4. What is rotation? A 2-D rotation is done by repositioning the coordinates along a circular path, in the x-y plane by making an angle with the axes. The transformation is given by: x' = xcos(θ) - ysin(θ) y' = xsin(θ) + ycos(θ) 17

5. What is scaling? The scaling transformations changes the shape of an object and can be carried out by multiplying each vertex (x,y) by scaling factor Sx,Sy where Sx is the scaling factor of x and Sy is the scaling factor of y. 6. What is shearing? The shearing transformation actually slants the object along the X direction or the Y direction as required.ie; this transformation slants the shape of an object along a required plane. 7. What is reflection? The reflection is actually the transformation that produces a mirror image of an object. For this use some angles and lines of reflection. 8. Distinguish between window port & view port? A portion of a picture that is to be displayed by a window is known as window port. The display area of the part selected or the form in which the selected part is viewed is known as view port. 9. Define clipping? Clipping is the method of cutting a graphics display to neatly fit a predefined graphics region or the view port. 10. What is covering (exterior clipping)? This is just opposite to clipping. This removes the lines coming inside the windows and displays the remaining. Covering is mainly used to make labels on the complex pictures. 11. What is the need of homogeneous coordinates? To perform more than one transformation at a time, use homogeneous coordinates or matrixes. They reduce unwanted calculations intermediate steps saves time and memory and produce a sequence of transformations. 12. Distinguish between uniform scaling and differential scaling? When the scaling factors sx and sy are assigned to the same value, a uniform scaling is produced that maintains relative object proportions. Unequal values for sx and sy result in a differential scaling that is often used in design application. 13. What is fixed point scaling? The location of a scaled object can be controlled by a position called the fixed point that is to remain unchanged after the scaling transformation..14. Determine a sequence of basic transformations that are equivalent to the x-direction shearing matrix. 18

15. Why are matrices used for implementing transformations. Matrices allow arbitrary linear transformations to be represented in a consistent format, suitable for computation. This also allows transformations to be concatenated easily (by multiplying their matrices). Review Questions: 1. Explain reflection and shear? 2. Explain Basic Transformations with procedure 3. Explain LCD and LED. 4. Derive the rotation transformation for rotating a point w.r.t. an arbitrary point. 5. Transform a square with vertices A(2,0), B(6,0), C(6,6) and D(2,6) to half its size and placed at location such that the centre of square moves to (0,0). What will be the effect of shearing this transformed square with x-shearing factor as 2? 6. What is the difference between a window and viewport? Derive the window-toviewport transformation of a point P(4,4) inside a circular window of radius 6 and centre (2,2) transformed onto a circular viewport of radius 3 and centre (-1,-1). 7. The triangle position is A(1,1),B(3,5) and C(2,2), translate the given triangle with respect to its centroid with A in the centroid position and rotate it by an angle 30.after shrinking the object half the size. 8. Describe the matrix formulation of 2-D transformations; translation, rotation and scaling. 9. Device the window-to-view port transformation and Elaborate.. 10. What is shearing transformation? Write down the X-direction shearing matrix for two dimension. Determine a sequence of basic transformations that are equivalent to the X-direction shearing. 19