Overview of Transformation in Computer Graphics

897 views 46 slides May 10, 2024
Slide 1
Slide 1 of 46
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34
Slide 35
35
Slide 36
36
Slide 37
37
Slide 38
38
Slide 39
39
Slide 40
40
Slide 41
41
Slide 42
42
Slide 43
43
Slide 44
44
Slide 45
45
Slide 46
46

About This Presentation

Overview of Transformation in Computer Graphics


Slide Content

Unit 3 : Overview Of Transformation Mr. C. P. Divate Department Of Computer Engineering

Contents

Two Dimensional 2D Transformations What is transformations? The geometrical changes of an object from it’s current state to another modified state is known as transformation. “Transformations are the operations applied to existing geometrical data of an object to change its position , orientation, or size are called geometric transformations”.

Two Dimensional 2D Transformations Why the transformations are needed? To manipulate the initially created object and to display the modified object without having to redraw it . To Change the shape of object. To Study the object surface details. To Study the future and past changes in objects. To modify old images. To get mirror image / Reflections of object. To change the color of objects. etc.

Two Dimensional 2D Transformations Translation- It is a process of Moving / shifting the position of an object from one location to another in a straight-line path. Rotation- It is a process rotating an object either Around itself. In clockwise or anti clockwise direction about any point on screen. Scaling- It is a process enlarging / Compressing an object size. Reflection- It is the process which gives mirror image of an object. Shearing- It is the process where object get distorted in different shape. Morphing- It is the process where object gets transit from between two shapes. Coloring- It is process where object gets colored. Types of Transformations?

Two Dimensional 2D Transformations Process of Transformation: It is a single step process in computer graphics where original object image is given as input to transformation process software and returns output as Transformed object image. Positional Vector: It is a representation of an original object image in computers memory. Usually represented in Matrix format (data structure). Process of Transformations Translation Rotation Scaling Reflection Shearing Morphing Coloring Original object image Transformed image Positional Vector Transformed Vector Geometric Operation / (Multiplication) [T ]

Two Dimensional 2D Transformations Geometric Operation: All Transformations can be performed with Mathematical Techniques only. In Computer Graphics transformations are performed with Matrix Calculations only. Especially it uses Matrix Multiplication Operation to perform above transformations. It has transformation matrix [ T ] of size 3 x 3 for each type of Transformation. Translation Rotation Scaling Reflection Shearing Morphing Coloring Original object image Transformed image Positional Vector Transformed Vector Geometric Operation / (Multiplication) [T] Process of Transformations

Two Dimensional 2D Transformations Transformed Vector: It is a representation of an Transformed object image in computers memory. Usually represented in Matrix format (data structure ). It has same matrix size as that of Positional Vector. Translation Rotation Scaling Reflection Shearing Morphing Coloring Original object image Transformed image Positional Vector Transformed Vector Geometric Operation / (Multiplication) [T ] Process of Transformations

Two Dimensional 2D Transformations Representation of Original Object / Positional Vector in Brain

Two Dimensional 2D Transformations Representation of Original Object / Positional Vector in Brain

Two Dimensional 2D Transformations Representation of Original Object / Positional Vector in Brain

Two Dimensional 2D Transformations Representation of Original Object / Positional Vector in Brain

Two Dimensional 2D Transformations Representation of Original Object / Positional Vector Why do we use matrix to represent Positional Vector? More convenient organization of data. More efficient processing Enable the combination of various concatenations Example 1: Consider a single point object P then, the Positional Vector in matrix form is, as follows, P = OR P =   P( x,y ) Column Matrix Form Row Matrix Form Note: In this Presentation we use Row Matrix Form to show all Transformations

Two Dimensional 2D Transformations Representation of Original Object / Positional Vector Example 2: Consider a line object P 1 P 2 then, the Positional Vector P in matrix form is, as follows, P = OR P =   Column Matrix Form Row Matrix Form   Example 3: Consider a Triangle object Δ P 1 P 2 P 3 then , the Positional Vector P in matrix form is, as follows, P = OR P =   P 1 (x1,y1) P 2 (x2,y2) P 3 (x3,y3)

Two Dimensional 2D Transformations Homogeneous co-ordinate system Positional Vector Example 2: Consider a line object P 1 P 2 P =   Example 3: Consider a Triangle object Δ P 1 P 2 P 3 P =   In 3D system there are three coordinates ( x, y, z ) to represent each pixel P. When we perform 2D transformation it is must that all points of the objects lies in single plane i.e. z = 1. When all pixels of the objects lies in same 2D plane e.g. z =1 the these pixels are known to be in homogeneous co-ordinate system.   When Object pixels are in 3D Space When Object pixels are in Homogeneous Coordinate system z=1 plane P =   P =     Note: In this Presentation we use Homogeneous PV to show all Transformations

Two Dimensional 2D Transformations Transformation Matrix / Geometric Operator [ T ] In Computer Graphics it uses matrix multiplications to Perform any Transformations on set of points represented in positional vector [ P ]. The Transformation matrix [ T ] is used to performed the desired Transformation. It is assumed that two matrices are known i.e. [ P ] and [ T ] and these are the input for all transformations. The Transformation Matrix [ T ] is of 3 X 3 size i.e. 3 rows and 3 col. Following is the Transformation Matrix [ T ]. [ T ] =     The desired Transformation is obtained with multiplication of [ P ] and [ T ] matrices. i.e. [ P ] x [ T ] = [ R ]

Two Dimensional 2D Transformations Transformation Matrix / Geometric Operator [ T ] The desired Transformation is obtained with multiplication of [ P ] and [ T ] matrices. i.e. [ P ] x [ T ] = [ R ] [ R ] = [ P ] . [ T ] =     X     R1 x 3 3 x C2 The Size of Resultant Matrix [ R ] is R1 x C2

Two Dimensional 2D Transformations Transformation by Unit Matrix If the Transformation Matrix [ T ] is Unit Matrix as follows. The desired Transformation is obtained with multiplication of [ P ] and [ T ] matrices. i.e. [ P ] x [ T ] = [ R ] Here Transformed Object is same as that of Original Object hence no transformation has done. So Object has not transformed and remain as it is at original positions. The Size of Resultant Matrix [ R ] is R1 x C2. [ T ] =       [ R ] = [ P ] . [ T ] =   X     R1 x 3 3 x C2 =     R1 x C2

Two Dimensional 2D Transformations 2D Scaling in Computer Graphics In scaling, we can expend or compress the size of any object . We can apply scaling on the object by multiplying the original coordinates with scaling factors Sx and Sy . The term scaling factor is used to define whether the size of an object is increased or decreased. We can represent the scaling factor by ‘ Sx ’ for the x-axis and ‘ Sy ’ for the y-axis. The Scaling Transformation is obtained with multiplication of [ P ] and [ T ] matrices. i.e. [ P ] x [ T ] = [ R ]. The Size of Resultant Matrix [ R ] is R1 x C2   [ R ] = [ P ] . [ T ] =   X     R1 x 3 3 x C2 =     R1 x C2

Two Dimensional 2D Transformations 2D Scaling in Computer Graphics   [ R ] = [ P ] . [ T ] =   X     R1 x 3 3 x C2 =     R1 x C2 Example: A Square object with the coordinate points D (1, 4), C (4, 4), B (4, 1), A (1,1). Apply the scaling factor 3 on the X-axis and 4 on the Y-axis. Find out the new coordinates of the square?

Two Dimensional 2D Transformations 2D Scaling in Computer Graphics - Enlargement   [ R ] = [ P ] . [ T ] =   X     R1 x 3 3 x C2 =     R1 x C2

Two Dimensional 2D Transformations 2D Scaling in Computer Graphics compression   [ R ] = [ P ] . [ T ] =   X     4 x 3 3 x C2 =     R1 x C2 Example: A Square object with the coordinate points D (1, 4), C (4, 4), B (4, 1), A (1,1). Apply the scaling factor 1 on the X-axis and 0.25 on the Y-axis. Find out the new coordinates of the square?

Two Dimensional 2D Transformations 2D Scaling in Computer Graphics - Compression   [ R ] = [ P ] . [ T ] =   X     4 x 3 3 x C2 =     R1 x C2

Two Dimensional 2D Transformations 2D Scaling Rules in Computer Graphics T= identity matrix: a=e=i=1, b=c=d==f=g=h=0 Results for all x’ = x, y’ = y. Scaling Rules by parameters a and e : b=c=d ==f=g=h=0 => x' = a.x , y ' = e.y ; This is scaling by a in x, d in y . If , a = e > 1, we have enlargement (scale up) & uniform scaling . If , a ≠ e > 1 , we have enlargement (scale up) & non-uniform scaling. If , 0 < a = e < 1 , we have compression (scale down) & uniform scaling. If , 0 < a ≠ e < 1 , we have compression (scale down) & non-uniform scaling . Uniform Scaling by parameter i: a = e = 1 and b=c=d==f=g=h=0 If, i > 1, we have compression ( scale down) & uniform scaling. If, i < 1, we have enlargement (scale up) & uniform scaling . If, i = 1, we have [ T ] as Unit Matrix hence results for all x’ = x, y’ = y. [ T ] =    

Two Dimensional 2D Transformations 2D Scaling in Computer Graphics compression   [ R ] = [ P ] . [ T ] =   X     4 x 3 3 x 3 =     4 x 3 Example: A Square object with the coordinate points D (1, 4), C (4, 4), B (4, 1), A (1,1). Apply the scaling factor 2 on both axis . Find out the new coordinates of the square? Some Observations and Imaginations are,

Two Dimensional 2D Transformations 2D Scaling in Computer Graphics compression Here Original object Matrix [ P ] is in One Homogeneous Co-ordinate Plane (z=1) plane. And The Resultant object Matrix [ R ] which is of same size, lies in another Homogeneous Co-ordinate Plane ( z=2) plane . It is needed to bring Resultant object of [ R ] in the same plane of [ P ] i.e. z = 1 Divide each row of [ R ] by third column element [ R ] =         [ R ] =

Two Dimensional 2D Transformations 2D Scaling in Computer Graphics compression [ R ] =    

Two Dimensional 2D Transformations 2D Scaling in Computer Graphics compression   [ R ] = [ P ] . [ T ] =   X     4 x 3 3 x 3 =     4 x 3 Example: A Square object with the coordinate points D (1, 4), C (4, 4), B (4, 1), A (1,1). Apply the scaling factor 0.5 on both axis . Find out the new coordinates of the square? Some Observations and Imaginations are,

Two Dimensional 2D Transformations 2D Scaling in Computer Graphics compression Here Original object Matrix [ P ] is in One Homogeneous Co-ordinate Plane (z=1) plane. And The Resultant object Matrix [ R ] which is of same size, lies in another Homogeneous Co-ordinate Plane ( z=0.5) plane . It is needed to bring Resultant object of [ R ] in the same plane of [ P ] i.e. z = 1 Divide each row of [ R ] by third column element [ R ] =     [ R ] =    

Two Dimensional 2D Transformations 2D Scaling in Computer Graphics compression [ R ] =    

Two Dimensional 2D Transformations 2D Reflection in Computer Graphics It is a transformation which produces a mirror image of an object. The mirror image can be either about x-axis or y-axis . The object is rotated by180 °. Types of Reflection: Reflection about the x-axis ( = 1, = -1) Reflection about the y-axis ( = -1 , = 1 ) Reflection about an axis perpendicular to xy plane and passing through the origin. ( = -1, = -1) Reflection about line y=x Here , can be either -1 for reflection.   The Reflection Transformation is obtained with multiplication of [ P ] and [ T ] matrices. i.e. [ P ] x [ T ] = [ R ]. The Size of Resultant Matrix [ R ] is R1 x C2.   [ R ] = [ P ] . [ T ] =   X     R1 x 3 3 x 3 =     R1 x 3

Two Dimensional 2D Transformations 2D Reflection in Computer Graphics 1. Reflection about x-axis: The object can be reflected about x-axis with the help of the follow ing matrix In this transformation va lue of x will remain same whereas the value of y will become negative . The Reflection Transformation is obtained with multiplication of [ P ] and [ T ] matrices. i.e. [ P ] x [ T ] = [ R ]. The Size of Resultant Matrix [ R ] is R1 x C2 .   [ R ] = [ P ] . [ T ] =   X     R1 x 3 3 x 3 =     R1 x C2 [ T ] = Following figures shows the reflection of the object axis. The object will lie another side of the x-axis

Two Dimensional 2D Transformations 2D Reflection in Computer Graphics 2. Reflection about y-axis: The object can be reflected about y-axis with the help of following transformation matrix In this transformation value of y will remain same whereas the value of x will become negative. The Reflection Transformation is obtained with multiplication of [ P ] and [ T ] matrices. i.e. [ P ] x [ T ] = [ R ]. The Size of Resultant Matrix [ R ] is R1 x C2 .   [ R ] = [ P ] . [ T ] =   X     R1 x 3 3 x 3 =     R1 x C2 The following figure shows the reflection about the y-axis [ T ] =

Two Dimensional 2D Transformations 2D Reflection in Computer Graphics 3. Reflection about an axis perpendicular to xy plane and passing through origin: In this value of x and y both will be reversed. This is also called as half revolution about the origin . The Reflection Transformation is obtained with multiplication of [ P ] and [ T ] matrices. i.e. [ P ] x [ T ] = [ R ]. The Size of Resultant Matrix [ R ] is R1 x C2 .   [ R ] = [ P ] . [ T ] =   X     R1 x 3 3 x 3 =     R1 x C2 The following figure shows the reflection about an axis perpendicular to xy plane [ T ] =

Two Dimensional 2D Transformations 2D Reflection in Computer Graphics 3. Reflection about an axis perpendicular to xy plane and passing through origin: In this value of x and y both will be reversed. This is also called as half revolution about the origin . The Reflection Transformation is obtained with multiplication of [ P ] and [ T ] matrices. i.e. [ P ] x [ T ] = [ R ]. The Size of Resultant Matrix [ R ] is R1 x C2 .   [ R ] = [ P ] . [ T ] =   X     R1 x 3 3 x 3 =     R1 x C2 The following figure shows the reflection about an axis perpendicular to xy plane [ T ] =

Two Dimensional 2D Transformations 2D Reflection in Computer Graphics 4. Reflection about line y=x: The object may be reflected about line y = x with the help of following transformation matrix In this value of x and y both will be exchanged. This is also called as reflection about y=x line. The Reflection Transformation is obtained with multiplication of [ P ] and [ T ] matrices. i.e. [ P ] x [ T ] = [ R ]. The Size of Resultant Matrix [ R ] is R1 x C2 .   [ R ] = [ P ] . [ T ] =   X     R1 x 3 3 x 3 =     R1 x C2 The following figure shows the reflection about an x=y line [ T ] =

Two Dimensional 2D Transformations 2D Reflection in Computer Graphics Problem-01: Given a triangle with coordinate points A(3, 4), B(6, 4), C(5, 6). Apply the reflection on the X axis and obtain the new coordinates of the object.   [ R ] = [ P ] . [ T ] =   X     R1 x 3 3 x 3 =     R1 x C2 Problem-02: Given a triangle with coordinate points A(3, 4), B(6, 4), C(5, 6). Apply the reflection on the X=Y Line to obtain the new coordinates of the object.   [ R ] = [ P ] . [ T ] =   X     R1 x 3 3 x 3 =     R1 x C2 Problem-03: Given a triangle with coordinate points A(3, 4), B(6, 4), C(5, 6). Apply the reflection on the Y axis to obtain the new coordinates of the object.

Two Dimensional 2D Transformations 2D Translation in Computer Graphics We can move any object from one to another place without changing the shape of the object. Translation of a Point: If we want to translate a point from P (x0, y0) to Q (x1, y1), then we have to add Translation coordinates ( Tx , Ty) with original coordinates . The Translation Transformation is obtained with multiplication of [ P ] and [ T ] matrices. i.e. [ P ] x [ T ] = [ R ]. The Size of Resultant Matrix [ R ] is R1 x C2 .   [ R ] = [ P ] . [ T ] =   X     R1 x 3 3 x 3 =   R1 x C2 The following figure shows the translation from P to Q Pixel.  

Two Dimensional 2D Transformations 2D Rotation in Computer Graphics In rotation, we rotate the object at particular angle θ theta from its origin. From the following figure, we can see that the point P(X,Y) is located at angle φ from the horizontal X coordinate with distance r from the origin. Let us suppose you want to rotate it at the angle θ . The Rotation Transformation is obtained with multiplication of [ P ] and [ T ] matrices. i.e. [ P ] x [ T ] = [ R ]. The Size of Resultant Matrix [ R ] is R1 x C2 . After rotating it to a new location, you will get a new point P’ (X ′,Y ′).

Two Dimensional 2D Transformations 2D Anticlockwise Rotation in Computer Graphics Using standard trigonometric the original coordinate of point P(X,Y) can be represented as − X= rcos ϕ......(1) Y= rsin ϕ......(2) Same way we can represent the point P’ X′,Y′ as − x′= rcos ( ϕ+θ)= r cos ϕ cos θ− r sin ϕ sin θ.......(3) y′= rsin ( ϕ+θ)= r cos ϕ sin θ+ r sin ϕ cos θ.......(4) Substituting equation 1 & 2 in 3 & 4 respectively, we will get x′ = xcos θ − ysin θ y ′ = xsin θ + ycos θ Representing the above equation in matrix form, [ R ] =[ X Y ] x   1 For Anti-clockwise Rotation   [ T ]=

Two Dimensional 2D Transformations 2D C lockwise Rotation in Computer Graphics For clockwise Rotation Consider Previous equations, x′ = xcos θ − ysin θ .......( 5) y′ = xsin θ + ycos θ ....... (6) Substituting equation - θ in 5 & 6, we will get x′ = xcos (- θ ) − y sin(- θ ) .......( 5) y′ = xsin (- θ ) + ycos (- θ ) ....... (6) Becomes, x′ = xcos θ − ( - ysin θ ) y′ = - xsin θ + ycos θ Results x′ = xcos θ + ysin θ .......( 7) y′ = - xsin θ + ycos θ ....... (8) Representing the above equation in matrix form, [ R ] =[ X Y ] x   1 For clockwise Rotation   [ T ]=

Two Dimensional 2D Transformations 2D Shearing in Computer Graphics A transformation that slants the shape of an object is called the shear transformation. There are two shear transformations X-Shear Y-Shear. X-Y Shear. One shifts X coordinates values and other shifts Y coordinate values . However in both the cases only one coordinate changes its coordinates and other preserves its values. Shearing is also termed as Skewing.

Two Dimensional 2D Transformations 2D Shearing in Computer Graphics X-Shear: The X-Shear preserves the Y coordinate and changes are made to X coordinates, which causes the vertical lines to tilt right or left as shown in below figure. The transformation matrix for X-Shear can be represented as −   For X-Shear   [ T ]=

Two Dimensional 2D Transformations 2D Shearing in Computer Graphics Y-Shear : The Y-Shear preserves the X coordinates and changes the Y coordinates which causes the horizontal lines to transform into lines which slopes up or down as shown in the following figure. The transformation matrix for Y-Shear can be represented as −   For Y-Shear   [ T ]=

Two Dimensional 2D Transformations 2D Shearing in Computer Graphics X-Y-Shear : The XY-Shear changes the X and Y coordinates which causes the horizontal and vertical lines to transform into lines which slopes up and down as shown in the following figure. The transformation matrix for Y-Shear can be represented as −   For Y-Shear   [ T ]=

Two Dimensional 2D Transformations Composite / Concatenation / Combined Transformation If a transformation of the plane T1 is followed by a second plane transformation T2, then the result itself may be represented by a single transformation T which is the composition of T1 and T2 taken in that order. This is written as T = [ T1 ] ∙ [ T2 ]. Composite transformation can be achieved by concatenation of transformation matrices to obtain a combined transformation matrix. A combined matrix − [ T ] = [ T1 ] [ T2 ] [ T3 ] [ T4 ] …. [ Tn ] Where [Ti] is any combination of- Translation, Scaling, Shearing, Rotation, Reflection The change in the order of transformation would lead to different results, as in general matrix multiplication is not cumulative, that is [A] . [B] ≠ [B] . [A] and the order of multiplication. The basic purpose of composing transformations is to gain efficiency by applying a single composed transformation to a point, rather than applying a series of transformation, one after another .
Tags