1 / 36

Unit-3 Chapter 5 2D TRANSFORMATIONS

Unit-3 Chapter 5 2D TRANSFORMATIONS. 2D Transformations. What is transformations? The geometrical changes of an object from a current state to modified state. Why the transformations is needed? To manipulate the initially created object and to display the modified object. 2D Transformations.

wbennett
Download Presentation

Unit-3 Chapter 5 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. Unit-3Chapter 52D TRANSFORMATIONS

  2. 2D Transformations • What is transformations? • The geometrical changes of an object from a current state to modified state. • Why the transformations is needed? • To manipulate the initially created object and to display the modified object.

  3. 2D Transformations • 2 ways • Object Transformation • Alter the coordinates descriptions an object • Translation, rotation, scaling etc. • Coordinate system unchanged • Coordinate transformation • Produce a different coordinate system

  4. a  c b  d Matrix Math • Matrix addition and subtraction • Matrix Multiplication • Dot product c a =  d b e f g h a b c d a.e + b.g a.f + b.h c.e + d.g c.f + d.h . =

  5. Geometric Transformations/object transformations • Basic transformations: • Translation • Scaling • Rotation • Purposes: • To move the position of objects • To alter the shape / size of objects • To change the orientation of objects

  6. A translation moves all points in an object along the same straight-line path to new positions. The path is represented by a vector, called the translation or shift vector. We can write the components: p'x= px + tx p'y= py + ty or in matrix form: P'= P+T ? =4 ty = 6 tx (2, 2) Translation x’ y’ x y tx ty = +

  7. Component-wise addition of vectors p’ = p + t where and x’ = x + dx y’ = y + dy To move polygons: translate vertices (vectors) and redraw lines between them Preserves lengths and Preserves angles. Example: 2D Translation 6 5 4 Y 3 2 1 0 1 2 3 4 5 6 7 8 9 10 X dx = 2 dy = 3 (Note: Points are at object’s local coordinate system origin)

  8. Rotation • A rotation repositions all points in an object along a circular path in the plane centered at the pivot point. • First, we’ll assume the pivot is at the origin. P’  P

  9. Rotation P’(x’, y’)  r y’ P(x,y) r  y  x x’ Identity of Trigonometry • Review Trigonometry => cos = x/r , sin = y/r • x = r. cos, y = r.sin  • => cos (+ ) = x’/r • x’ = r. cos (+ ) • x’ = r.coscos -r.sinsin • x’ = x.cos  – y.sin  • =>sin (+ ) = y’/r y’ = r. sin (+ ) • y’ = r.cossin + r.sincos • y’ = x.sin  + y.cos 

  10. Rotation • We can write the components: • p'x = px cos  – py sin  • p'y= px sin  + py cos  • or in matrix form: • P' = R •P •  can be clockwise (-ve) or counterclockwise (+ve as our example). • Rotation matrix P’(x’, y’)  y’ P(x,y) r  y  x x’

  11. Rotation • Example • Find the transformed point, P’, caused by rotating P= (5, 1) about the origin through an angle of 90.

  12. Scaling P’ P • Scaling changes the size of an object and involves two scale factors, Sx and Sy for the x- and y- coordinates respectively. • Scales are about the origin. • We can write the components: p'x = sx•px p'y = sy•py or in matrix form: P' = S •P Scale matrix as:

  13. Scaling • Example : • P(2, 5), Sx = 0.5, Sy = 0.5 • Find P’ ? P(2, 5) P’ • If the scale factors are in between 0 and 1  the points will be moved closer to the origin  the object will be smaller.

  14. Scaling P’ • Example : • P(2, 5), Sx = 0.5, Sy = 0.5 • Find P’ ? P(2, 5) P’ • Example : • P(2, 5), Sx = 2, Sy = 2 • Find P’ ? • If the scale factors are in between 0 and 1  the points will be moved closer to the origin  the object will be smaller. • If the scale factors are larger than 1  the points will be moved away from the origin  the object will be larger.

  15. Scaling P’ P(1, 2) • If the scale factors are the same, Sx = Sy uniform scaling • Only change in size (as previous example) • If Sx Sy  differential scaling. • Change in size and shape • Example : square  rectangle • P(1, 3), Sx = 2, Sy = 5 , P’ ?

  16. Homogenous Coordinates y x • 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)

  17. Homogenous Coordinates • We can always map back to the original 2D point by dividing by the last coordinate • (15, 6, 3) --- (5, 2). • (60, 40, 10) - ?. • Why do we use 1 for the last coordinate? • The fact that all the points along each line can be mapped back to the same point in 2D gives this coordinate system its name – homogeneous coordinates.

  18. Matrix Representation x y 1 • Point in column-vector: • Our point now has three coordinates. • So our matrix needs to be 3x3. • Translation

  19. Matrix Representation • Rotation • Scaling

  20. Transformations. • Translation. • P=T * P • Scale • P=S  P • Rotation • P=R  P • We would like all transformations to be multiplications

  21. Translate [1,3] by tx=7 and ty=9 Scale [2,3] by 5 in the X direction and 10 in the Y direction Rotate [2,2] by 90° (π/2) Examples

  22. Composite Transformation • Translation • If two successive translation factor (tx1, ty1) and (tx2, ty2) are applied to a coordinate point P then • Two successive Translation are additive

  23. Composite Transformation • Rotation • two successive rotation two successive rotations are also additive • Scaling • successive scalings are multiplicative

  24. Composite Transformation • Rotate about an arbitrary point – translate, rotate, translate • Scale about an arbitrary point – translate, scale, translate • Change coordinate systems – translate, rotate, scale • Does the order of operations matter?

  25. Order of operations So, it does matter. Let’s look at an example: • Rotate • Translate • Translate • Rotate

  26. Composite Transformation Matrix cos -sin 0 sin cos 0 0 0 1 1 0 tx 0 1 ty 0 0 1 1 0 -tx 0 1 -ty 0 0 1 . . cos -sin -tx cos+ ty sin sin cos -tx sin - ty cos 0 0 1 1 0 tx 0 1 ty 0 0 1 . cos -sin -tx cos+ ty sin + tx sin cos -tx sin - ty cos + ty 0 0 1 • Arrange the transformation matrices in order from right to left. • General Pivot- Point Rotation • Operation :- • Translate (pivot point is moved to origin) • Rotate about origin • Translate (pivot point is returned to original position) T(pivot) • R() • T(–pivot)

  27. x y 1 . 2 5 1 0.5 -0.866 -1.0.5 + 2.0.866 + 1 0.866 0.5 -1.0.866- 2.0.5 + 2 0 0 1 . 2 5 1 -1.098 4.366 1 0.5 - 0.866 2.232 0.866 0.5 0.134 0 0 1 . = cos -sin -tx cos+ ty sin+ tx sin cos -tx sin - ty cos + ty 0 0 1 Composite Transformation Matrix • Example • Perform 60 rotation of a point P(2, 5) about a pivot point (1,2). Find P’? Sin 60 = 0.8660 Cos 60 = 1/2 P’ = (-1, 4)

  28. Composite Transformation Matrix General Fixed-Point Scaling Operation :- • Translate (fixed point is moved to origin) • Scale with respect to origin • Translate (fixed point is returned to original position) T(fixed) • S(scale) • T(–fixed) Find the matrix that represents scaling of an object with respect to any fixed point? Given P(6, 8) , Sx = 2, Sy = 3 and fixed point (2, 2). Use that matrix to find P’?

  29. Answer Sx 0 0 0 Sy 0 0 0 1 1 0 tx 0 1 ty 0 0 1 1 0 -tx 0 1 -ty 0 0 1 . . Sx 0 -tx Sx 0 Sy -ty Sy 0 0 1 1 0 tx 0 1 ty 0 0 1 Sx 0 -tx Sx + tx 0 Sy -ty Sy + ty 0 0 1 = . x =6, y = 8, Sx = 2, Sy = 3, tx =2, ty = 2 2 0 -2(2) + 2 0 3 -2(3) + 2 0 0 1 6 8 1 10 20 1 . =

  30. Composite Transformation Matrix General Scaling Direction Operation :- 1. Rotate (scaling direction align with the coordinate axes) 2. Scale with respect to origin 3. Rotate (scaling direction is returned to original position) R(–) • S(scale) • R() Find the composite transformation matrix by yourself !!

  31. Other transformations Reflection: Mirror image x-axis y-axis

  32. Other transformations Reflection: origin line x=y

  33. Other transformations Shear: A transformation that distorts the shape of an object such that the transformed shape appears as if the object were composed of internal layers that had been caused to slid over each other is called shear. x-direction y-direction

  34. Other transformations Shear: x-direction shearing Y-direction shearing relative to other relative to other ref. line ref. line(yref=-1) (xref=-1) Xref=-1 Yref=-1

  35. Coordinate System Transformations • We often need to transform points from one coordinate system to another: • We might model an object in non-Cartesian space (polar) • Objects may be described in their own local system • Other reasons: textures, display, etc

  36. Questions…?

More Related