1 / 14

2D Transformations

2D Transformations. To rotate a line or polygon, we must rotate each of its vertices. To rotate point (x 1 ,y 1 ) to point (x 2 ,y 2 ) we observe: From the illustration we know that: sin (A + B) = y 2 /r cos (A + B) = x 2 /r sin A = y 1 /r cos A = x 1 /r. y-axis. (x2,y2). (x1,y1).

vance
Download Presentation

2D Transformations

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 2D Transformations

  2. 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 y-axis (x2,y2) (x1,y1) r B A (0,0) Rotation About the Origin x-axis

  3. . P2 = R P1 (x2) (y2) (cosB -sinB) (sinB cosB) (x1) (y1) = 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

  4. 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. Ty Tx Translations P2 = P1 + T P1 = ( x1 ) ( y1 ) T = ( tx ) ( ty ) P2 = (x1 + tx) (y1 + ty)

  5. 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. Scaling . P2 = S P1 S = (sx 0) (0sy) P1 = ( x1 ) ( y1 ) P2 = (sxx1) (syy1)

  6. 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 Homogeneous Coordinates (x) (y) (1) Point P =

  7. 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) Composite Transformations - Scaling (4) (1) (1) (2) (1) (1) (4) (1) (1) (8) (1) (1)

  8. 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) Composite Transforms - Scaling (cont.) (0) (1) (1) (0) (1) (1) (0) (1) (1) (2) (1) (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.

  9. 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) Fixed Point Scaling (2) (1) (1) (2) (1) (1) (4) (1) (1) (6) (1) (1)

  10. 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) More Fixed Point Scaling (2) (1) (1) (1) (1) (1) (4) (1) (1) (5) (1) (1)

  11. Rotation of ø Degrees About Point (x,y) Translate (x,y) to origin Rotate Translate origin to (x,y) Rotation about a Fixed Point (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.

  12. 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 Shears

  13. 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 Reflections

  14. 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 More Reflections

More Related