Presentation is loading. Please wait.

Presentation is loading. Please wait.

Part7: Geometric Transformations

Similar presentations


Presentation on theme: "Part7: Geometric Transformations"— Presentation transcript:

1 Part7: Geometric Transformations
Computer Graphics Part7: Geometric Transformations

2 April 23, 2017 2D Transformations Transformation means changes in orientation, size, and shape. The basic geometric transformations are translation, rotation, and scaling. Other transformations that are often applied to objects include reflection and shear ( جز).

3 Transformations Translation Rotation Scaling moving things
April 23, 2017 Transformations Translation moving things Rotation moving about a point by a given angle rotation point may be origin or some other chosen point Scaling changing size relative to origin or some other chosen point

4 2D Translation Repositioning an object along a straight line path from one co-ordinate location to another (x,y) (x’,y’) To translate a 2D position, we add translation distances tx and ty to the original coordinates (x,y) to obtain the new coordinate position (x’,y’) x’= x + tx , y’= y + ty T x y Matrix form

5 April 23, 2017 2D TRANSLATION Example: Let P = (5, 9), T = (tx, ty) = ( 6, 8) , so P' = (11, 17) Note: To translate a line translate its endpoints. To translate polygon ( مضلع) translate its vertices. Circle or Ellipse: Translate boundary points.

6 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 (a) (b)

7 April 23, 2017 2D TRANSLATION We think of a point as a column vector, written as a column of numbers between parentheses. We add vectors by adding corresponding coordinates.

8 2D Rotation Repositioning an object along a circular path in the xy-plane x y (x,y) (x’,y’) φ θ r The original coordinates are:

9 2D Rotation Substituting x y (x,y) (x’,y’) φ θ r Matrix form

10 2D Rotation Example Cos 90 = 0 Sin 90 = 1
Rotate the line endpoints (1,2) and ( 4,3) about origin by 90 degree. p(1,2) >>>>> p’(-2,1) x’=1*cos 90 – 2*sin 90 = -2 y’=1*sin *cos 90= 1 P(4,3) >>>>>>> p’(-3,4) x’=4*cos 90 – 3*sin 90= -3 y’=4*sin *cos 90= 4 Cos 90 = 0 Sin 90 = 1

11 2D Rotation about a Pivot position
Rotating about pivot position (xr, yr) x y (x,y) (x’,y’) φ θ r xr yr

12 Example Rotate the line endpoints (2,1) about point (3,3) by 90
x’=3+(2-3) cos 90 – (1-3) sin 90 x’=3—2=5 y’=3+(2-3) sin 90 + (3-1) cos 90 = 3-1=2

13 2D Scaling Altering the size of an object. Sx and Sy are the scaling factors. If Sx = Sy then uniform scaling. Sx and Sy can be any positive value. – Values < 1 reduces the size of the object. – Values > 1 produces and enlargement. – If Sx and Sy is 1, then the size is unchanged. Matrix form

14 2D Scaling relative to Fixed point
Scaling relative to fixed point (xf, yf) x y Sx = ¼ , Sy = ½ P1 P2 P3 P1’ P2’ P3’ (xf , yf)

15 Matrix Representation
Use 3×3 matrices to combine transformations Translation Rotation Scaling

16 Inverse Transformations
Translation Rotation Scaling

17 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)

18 Result x y x y x y T(-20, -10) R(90º) (30, 25) (-15, 10) (10, 10)
(0, -10) (-15, 10) x y (10, 15) (-10, 0) x y (0, -10) (-15, 10) T(-20, -10) R(90º)

19 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

20 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

21 Exercises Consider the following object:
Scale it by sx = 2 and sy = ½ relative to the fixed point (140, 125) and display it. Apply a rotation by 90° on the Pivot Point (50, 60) and then scale it by sx = sy = 2 relative to the Fixed Point (0, 200). Display the result. Scale it sx = sy = ½ relative to the Fixed Point (50, 60) and then rotate it by 180° on the Pivot Point (50, 60). Display the final result. x y 60 50 125 220

22 (x,y,z) (x’,y’,z’) x’= x + tx , y’= y + ty , z’= z + tz
3D Translation (x,y,z) (x’,y’,z’) x’= x + tx , y’= y + ty , z’= z + tz Matrix form (4 × 4) T(tx, ty, tz) x y z

23 3D Rotation z-axis: x y z Matrix form x y z

24 3D Rotation x-axis: x y z Matrix form

25 3D Rotation y-axis: x y z Matrix form

26 3D Scaling x y z Matrix form


Download ppt "Part7: Geometric Transformations"

Similar presentations


Ads by Google