2D Transformations

67 %
33 %
Information about 2D Transformations
Education

Published on March 5, 2009

Author: ankush85

Source: authorstream.com

2D Transformations : 2D Transformations Rotation About the Origin : Rotation About the Origin To rotate a line or polygon, we must rotate each of its vertices. To rotate point (x1,y1) to point (x2,y2) we observe: From the illustration we know that: sin (A + B) = y2/r cos (A + B) = x2/r sin A = y1/r cos A = x1/r x-axis Rotation About the Origin : Rotation About the Origin From the double angle formulas: sin (A + B) = sinAcosB + cosAsinB cos (A + B)= cosAcosB - sinAsinB Substituting: y2/r = (y1/r)cosB + (x1/r)sinB Therefore: y2 = y1cosB + x1sinB We have x2 = x1cosB - y1sinB y2 = x1sinB + y1cosB Translations : Translations Moving an object is called a translation. We translate a point by adding to the x and y coordinates, respectively, the amount the point should be shifted in the x and y directions. We translate an object by translating each vertex in the object. P2 = P1 + T T = ( tx ) ( ty ) P1 = ( x1 ) ( y1 ) P2 = (x1 + tx) (y1 + ty) Scaling : Scaling Changing the size of an object is called a scale. We scale an object by scaling the x and y coordinates of each vertex in the object. P2 = S P1 . S = (sx 0) (0 sy) P1 = ( x1 ) ( y1 ) P2 = (sxx1) (syy1) Homogeneous Coordinates : Homogeneous Coordinates Although the formulas we have shown are usually the most efficient way to implement programs to do scales, rotations and translations, it is easier to use matrix transformations to represent and manipulate them. In order to represent a translation as a matrix operation we use 3 x 3 matrices and pad our points to become 1 x 3 matrices. cos ø -sin ø 0 Rø = sin ø cos ø 0 0 0 1 Sx 0 0 S = 0 Sy 0 0 0 1 1 0 Tx T = 0 1 Ty 0 0 1 Point P = (x) (y) (1) Composite Transformations - Scaling : Composite Transformations - Scaling Given our three basic transformations we can create other transformations. Scaling with a fixed point A problem with the scale transformation is that it also moves the object being scaled. Scale a line between (2, 1) (4,1) to twice its length. (2 0 0) = (0 1 0) (0 0 1) (2 0 0) = (0 1 0) (0 0 1) (2) (1) (1) (4) (1) (1) (4) (1) (1) (8) (1) (1) Composite Transforms - Scaling (cont.) : Composite Transforms - Scaling (cont.) If we scale a line between (0, 1) (2,1) to twice its length, the left-hand endpoint does not move. (2 0 0) = (0 1 0) (0 0 1) (2 0 0) = (0 1 0) (0 0 1) (0,0) is known as a fixed point for the basic scaling transformation. We can used composite transformations to create a scale transformation with different fixed points. (0) (1) (1) (0) (1) (1) (2) (1) (1) (0) (1) (1) Fixed Point Scaling : Fixed Point Scaling Scale by 2 with fixed point = (2,1) Translate the point (2,1) to the origin Scale by 2 Translate origin to point (2,1) (1 0 2) (2 0 0) (1 0 -2) = (2 0 -2) (0 1 1) (0 1 0) (0 1 -1) (0 1 0) (0 0 1) (0 0 1) (0 0 1) (0 0 1) (2 0 -2) = (0 1 0) (0 0 1) (2 0 -2) = (0 1 0) (0 0 1) (2) (1) (1) (2) (1) (1) (4) (1) (1) (6) (1) (1) More Fixed Point Scaling : More Fixed Point Scaling Scale by 2 with fixed point = (3,1) Translate the point (3,1) to the origin Scale by 2 Translate origin to point (3,1) (1 0 3) (2 0 0) (1 0 -3) = (2 0 -3) (0 1 1) (0 1 0) (0 1 -1) (0 1 0) (0 0 1) (0 0 1) (0 0 1) (0 0 1) (2 0 -3) = (0 1 0) (0 0 1) (2 0 -3) = (0 1 0) (0 0 1) (2) (1) (1) (1) (1) (1) (4) (1) (1) (5) (1) (1) Rotation about a Fixed Point : Rotation about a Fixed Point Rotation of ø Degrees About Point (x,y) Translate (x,y) to origin Rotate Translate origin to (x,y) (1 0 x) (cosø -sinø 0)(1 0 -x) (cosø -sinø -xcosø + ysinø + x ) (0 1 y) (sinø cosø 0)(0 1 -y) = (sinø cosø -xsinø - ycosø + y ) (0 0 1) (0 0 1)(0 0 1) (0 0 1 ) You rotate the box by rotating each vertex. Shears : Shears Original Data y Shear x Shear 1 0 0 1 b 0 a 1 0 0 1 0 0 0 1 0 0 1 GRAPHICS --> x shear --> GRAPHICS Reflections : Reflections Reflection about the y-axis Reflection about the x-axis -1 0 0 1 0 0 0 1 0 0 -1 0 0 0 1 0 0 1 More Reflections : More Reflections Reflection about the origin Reflection about the line y=x -1 0 0 0 1 0 0 -1 0 1 0 0 0 0 1 0 0 1

Add a comment

Related presentations

Related pages

2D Transformations - Willamette University

2D Transformations. Transformaions are a fundamental part of computer graphics. Transformations are used to position objects, to shape objects, to change ...
Read more

2D Transformations \ Processing.org

Processing is a flexible software sketchbook and a language for learning how to code within the context of the visual arts. Since 2001, Processing has ...
Read more

CSS3 2D Transforms - W3Schools Online Web Tutorials

CSS3 Transforms. CSS3 transforms allow you to translate, rotate, scale, and skew elements. A transformation is an effect that lets an element change shape ...
Read more

Transformation matrix - Wikipedia, the free encyclopedia

In linear algebra, linear transformations can be represented by matrices. If T is a linear transformation mapping R n to R m and is a column vector with n ...
Read more

Übersicht über Transformationen

In diesem Thema wird die Verwendung von 2D Transform-Klassen zum Drehen, Skalieren, ... Beispiel für 2D-Transformation. Community-Beiträge. Anzeigen: ...
Read more

Koordinatentransformation – Wikipedia

Die Parameter dieser Transformation sind die Zahlen . ... Im 2D-Raum gibt es daher einen Parameter und im 3D-Raum drei Parameter. Affine Transformationen ...
Read more

Intro to Computer Graphics: 2D Transformations

Transformations in 2 Dimensions References: Andy Johnson's CS 488 Course Notes, Lecture 5 Foley, Van Dam, Feiner, and Hughes, "Computer Graphics ...
Read more

2D computer graphics - Wikipedia, the free encyclopedia

2D computer graphics is the computer-based generation of digital images—mostly from two-dimensional models (such as 2D geometric models, text, and ...
Read more

361-06: 2D Transformations - Computing Science - Simon ...

2D Transformations CMPT 361 Introduction to Computer Graphics Torsten Möller ... Homogeneous coordinates for 2D points – (x, y) turns into (x, y, W)
Read more

CSS3 3D Transforms - W3Schools Online Web Tutorials

CSS3 3D Transforms. CSS3 allows you to format your elements using 3D transformations. Mouse over the elements below to see the difference between a 2D and ...
Read more