Presentation is loading. Please wait.

Presentation is loading. Please wait.

Computer Graphics Lecture 18 3-D Transformations-II Taqdees A

Similar presentations


Presentation on theme: "Computer Graphics Lecture 18 3-D Transformations-II Taqdees A"— Presentation transcript:

1 Computer Graphics Lecture 18 3-D Transformations-II Taqdees A
Computer Graphics Lecture D Transformations-II Taqdees A. Siddiqi

2 Rotation Rotation is the process of moving a point in space in a non-linear manner

3 Normalization Note that the process of moving the points so that the POV is at the origin looking down the +Z axis is called normalization.

4 For Rotation Rotating a point requires that we know:
1)  the coordinates for the point, and 2)  the rotation angles

5 We need to know three different angles:
How far to rotate around the X axis(YZ rotation, or “pitch”) How far to rotate around the Y axis (XZ rotation, or “yaw”) How far to rotate around the Z axis (XY rotation, or “roll”)

6 Rotating a Point

7 Repositions an object along a circular path in xy-plane
Rotation Angle θ Rotation Point (xr, yr) θ is +ve  counterclockwise rotation θ is -ve  clockwise rotation θ is zero  ?

8 For simplicity, consider the pivot at origin and rotate point P (x,y) where x = r cosФ and y = r sinФ If rotated by θ then: x′ = r cos(Ф + θ) = r cosФ cosθ – r sinФ sinθ and y′ = r sin(Ф + θ) = r cosФ sinθ + r sinФ cosθ

9 Replacing r cosФ with x and r sinФ with y, we have:
x′ = x cosθ – y sinθ and y′ = x sinθ + y cosθ

10 Column vector representation: P′ = R . P
Where

11 Rotation: Homogeneous Coordinates
The rotation can now be expressed using homogeneous coordinates as: Abbreviated as: P’ = R (θ) . P

12 … Now in 3D Rotation can be about any of the three axes:
About z-axis (i.e. in xy plane) About x-axis (i.e. in yz plane) About y-axis (i.e. in xz plane)

13 Roll : around z-axis

14 Pitch: around x-axis

15 Yaw: around y-axis

16 Rotation about z-axis (i.e. in xy plane):
x′ = x cosθ – y sinθ y′ = x sinθ + y cosθ z’ = z

17

18 Cyclic Permutations of Coordinate Axes
Alright, but what about rotations w.r.t. other axes? Cyclic Permutations of Coordinate Axes

19 Cyclic permutation

20 Rotation about x-axis (i.e. in yz plane):
x′ = x y′ = y cosθ – z sinθ z′ = y sinθ + z cosθ

21 Rotation about y-axis (i.e. in xz plane):
x′ = z sinθ + x cosθ y ′ = y z′ = z cosθ – x sinθ

22 Matrix Representations

23 Rotation about z-axis P` = Rz(θ) . P

24 Rotation about x-axis P` = Rx(θ) . P

25 Rotation about y-axis P` = Ry(θ) . P

26 Example Let's manually rotate the point (2,0,0) 45 degrees clockwise about the z axis

27

28 Around arbitrary axis

29 Around arbitrary axis

30 Around arbitrary axis

31 Around arbitrary axis

32 Composite Transformation
Now you can take an object and apply a sequence of transformations to it to make it do whatever you want. All you need to do is figure out the sequence of transformations needed and then apply the sequence to each of the points in the model.

33 As an example, let's say you want to rotate an object sitting at a certain point p around its z axis. You would perform the following sequence of transformations to achieve this

34

35

36 Around arbitrary axis

37

38

39

40

41

42 Scaling

43 Scaling an object changes its size and repositions the object relative to the coordinate origin. If the transformation parameters are not all equal, relative dimensions in the object are changed

44 Coordinate transformations for scaling relative to the origin are
X` = X . Sx Y` = Y . Sy Z` = Z . Sz

45 1) Uniform Scaling 2) Differential Scaling

46 Uniform Scaling We preserve the original shape of an object with a uniform scaling ( Sx = Sy = Sz)

47 Differential Scaling We do not preserve the original shape of an object with a differential scaling ( Sx <> Sy <> Sz)

48 Scaling w.r.t. Origin

49 Scaling w.r.t. a fixed position
Scaling with respect to a selected fixed position (Xf,Yf,Zf) can be represented with the transformation sequence: 

50 Transformation sequence
Translate the fixed point to the origin. Scale the object relative to the coordinate origin Translate the fixed point back to its original position

51 Composite Transformation

52 Composite Transformation

53 Reflection A reflection can be performed relative to a selected reflection axis or with respect to a selected reflection plane.

54 In general, three-dimensional reflection matrices are set up similarly to those for two dimensions. Reflections relative to a given axis are equivalent to 180 degree rotations.

55 Reflection of points relative to the X axis

56 Reflection of points relative to the Y axis

57 Reflection of points relative to the xy plane

58 Shears

59 Shearing transformations can be used to modify object shapes

60 As an example of three-dimensional shearing, the following transformation produces a z-axis shear:

61 Y-axis shear

62 X-axis shear

63 Computer Graphics Lecture 18

64 Rotation w.r.t. y-axis: P` = Ry(θ) . P

65 From the drawing and elementary trigonometry, we can say:
cos(q) = X/D or D = X /cos(q) sin(q) = Y/D or D = Y/sin(q)

66 where D = hypotenuse = length of vector from origin to (x,y) To rotate to our new point, we just add m to q For our new point, we know that: cos ( q + m) = X` / D sin ( q + m) = Y`/ D

67 X` = D * cos ( q + m ) Y` = D * sin ( q + m )

68 We can expand these using the addition formulas

69 cos ( q + m ) = cos ( q ) * cos ( m ) –
sin( q ) * sin ( m )

70 X` = D * cos (q + m ) =D*[cos ( q ) * cos( m ) – sin ( q ) * sin ( m )] =D*cos ( q ) * cos ( m ) – D*sin ( q )*sin( m )

71 But we noted that D= X / cos(q) D= Y/sin(q) so we can substitute them in :

72 X`= [X / cos(q)] * cos (q) * cos(m) – [Y/sin(q) ] *sin(q) * sin(m)
= X * cos(m) – Y*sin(m)

73 And we can follow a similar approach to find Y`

74 Y` = D*sin(q+m) = D*[sin(q) * cos(m) + cos(q) * sin(m)] = D*sin(q) * cos(m) + D*cos(q) * sin(m)

75 Y` = [ X/ cos(m)] * sin(q ) *cos(m) + [Y/sin(m) ] * cos(q ) * sin(m)
= X * sin(q) + Y*cos(q)

76 So to rotate the point (x,y,z) around the Z axis through an angle of M degrees, we use:
X` = x*cos(M) – y*sin(M) Y` = x*sin(M) + y*cos(M) Z` = z

77 You see, in the above, we rotate M degrees around the Z axis (“roll”), moving from the +X axis to the +Y axis But if you look down on the XY plane from the +Z axis, this is a –M degree rotation!

78 you can go through a similar process to calculate the rotation formula for rotating around the X axis (“pitch”) and around the Y axis (“yaw”), ending up with:

79 Roll ( rotate around Z axis):
x` = x * cos(m ) + y* sin(m) y` = y* cos(m) – x * sin(m) z` = z

80 Pitch ( rotate around the X axis):
x` = x y` = y * cos(m) + z * sin(m) z` = z * cos(m) – y*sin(m)

81 Yaw ( rotate about the Y axis):
x` = x * cos(m) – z * sin(m) y` = y; z` = x * sin(m) + z * cos(m)

82 Using Matrices for Rotation

83 Roll (rotate about the Z axis)
| cos(m) sin(m) 0 0 | | -sin(m) cos(m) 0 0 | | | | | or P` = Rz(m) . P

84 Pitch (rotate about the X axis)
| | | 0 cos(m) sin(m) 0 | | 0 -sin(m) cos(m) 0 | | | or P` = Rx(m) . P

85 Yaw (rotate about the Y axis)
| cos(m) 0 -sin(m) 0| | | | sin(m) 0 cos(m) 0| | |  or P` = Ry(m) . P


Download ppt "Computer Graphics Lecture 18 3-D Transformations-II Taqdees A"

Similar presentations


Ads by Google