0% found this document useful (0 votes)
45 views13 pages

Chapter 4

The document discusses geometrical transformations in 2D and 3D spaces. It covers matrix representations of translations, rotations, and scaling in 2D. Translations shift all points by a certain amount in the x and y directions. Rotations rotate points around a center of rotation by a given angle. Scaling transformations multiply each coordinate by respective scale factors. The document also introduces homogeneous coordinates to represent transformations using matrix multiplications, allowing combinations of multiple transformations.

Uploaded by

beki BA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views13 pages

Chapter 4

The document discusses geometrical transformations in 2D and 3D spaces. It covers matrix representations of translations, rotations, and scaling in 2D. Translations shift all points by a certain amount in the x and y directions. Rotations rotate points around a center of rotation by a given angle. Scaling transformations multiply each coordinate by respective scale factors. The document also introduces homogeneous coordinates to represent transformations using matrix multiplications, allowing combinations of multiple transformations.

Uploaded by

beki BA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

Chapter 4 Geometrical Transformations

 Matrix Representation
 Transformation
2d transformations
Chapter 4

 3d transformations
Geometrical Transformations  Homogeneous Coordinates
 Combination of Transformations

2 Prepared By Haftom B. 5/20/2022

Matrix Transformations CONT..


 First of all let us review some basics of matrices. 2x2 matrices can be  Matrix multiplication is not commutative. In other words, for two matrices
multiplied according to the following equation . A and B, AB≠BA. We can see this from the following example.

 However, matrix multiplication is associative. This means that if we have


three matrices A, B and C, then (AB)C = A(BC). We can see this from the
following example.

3 Prepared By Haftom B. 5/20/2022 4 Prepared By Haftom B. 5/20/2022


1. 2D- Translation CONT..
 The translation transformation shifts all points by the same To translate a point P to P’ we add on a vector T:
amount.  px 
P   
 …………………………………………………
 A translation is applied to an object by repositioning it along a straight-
 py 
line path from one coordinate location to another.
 p x 
 therefore, in 2-D, we must define two translation P    
 …………………………………………………
 p y 
parameters:
 tx 
 the x-translation tx T    …………………………………………………
ty 
 the y-translation ty.
 p x   px   tx 
     
 p    p   t  …………………………………………
 y   y   y 
5 Prepared By Haftom B. 5/20/2022 6 Prepared By Haftom B. 5/20/2022

Example translate the following triangle 2. 2-D Rotation


 Given (2,3) ,(1,1),(3,1) and translation matrix =(3,1)  The rotation transformation rotates all points about a center of rotation.
 Normally this center of rotation is assumed to be at the origin (0,0), although
p x  p x  t x as we will see later on it is possible to rotate about any point.
 The rotation transformation has a single parameter:
p y  p y  t y  The angle of rotation, θ.
 To rotate a point P anti-clockwise by θo, we apply the rotation matrix R:
 (2+3,3+1)=(5,4)
 (1+3,1+1)=(4,2)
 (3+3,1+1)=(6,2)

7 Prepared By Haftom B. 5/20/2022 8 Prepared By Haftom B. 5/20/2022


Cont.. 3. 2-D Scaling
 Therefore, we can see that the relationship between points before and after  The scaling transformation multiplies each coordinate of each point by a scale
the rotation is: factor.
  The scale factor can be different for each coordinate (e.g. for the x and y
coordinates).
 If all scale factors are equal, we call it uniform scaling, whereas if they are
different, we call it differential scaling.
 To scale a point P by scale factors Sx and Sy we apply the scaling matrix S:

9 Prepared By Haftom B. 5/20/2022 10 Prepared By Haftom B. 5/20/2022

Example of Scaling Homogeneous Coordinates


 Given (2,3) ,(1,1),(3,1) and Scaling Factor Sx,Sy)=(2,2)  To express any two-dimensional transformation as a matrix multiplication, we
 p’x=Sx*px=2*2=4 represent each Cartesian coordinate position (x, y) with the homogeneous
 P’y=Sy*Py=3*2=6 coordinate triple (xh, yh, h), where:
 p’x=Sx*px=1*2=2  Coordinates are represented with three-element row vectors, and
transformation operations are written as 3 by 3 matrices
 P’y=Sy*Py=1*2=2
 For translation, we have:
 p’x=Sx*px=3*2=6 exactly the same as before,
 P’y=Sy*Py=1*2=2 Therefore but we used a matrix
 Therefore ,px  p x  t x multiplication instead of an
py  p y  t y addition.
 (4,6) ,(2,2),(6,2)

11 Prepared By Haftom B. 5/20/2022 12 Prepared By Haftom B. 5/20/2022


Cont.… Cont..
 Similarly, rotation transformation equations about the coordinate origin are  A scaling transformation relative to the coordinate origin is now expressed as
now written as: the matrix multiplication

 =  =
 Sx 0 0
 
S  0 Sy 0
0 0 1 

 px   S x 0 0  p x 
    
 py    0 Sy 0  p y 
 Therefore px  p x cos   p y sin  and p y  p y cos   p y sin  , which is the same outcome as before.  1  0 0 1  1 
  

13 Prepared By Haftom B. 5/20/2022 14 Prepared By Haftom B. 5/20/2022

Examples Cont...
 Given a square with vertices at p1 = (10, 15), p2 = (15, 15), p3 = (15, 20) and p4 = (10,
20). Translate the points by (10, 5) using translation matrix.  P3 = (15, 20)
 Solution:

 Tx = 10, Ty = 5

 P4 = (10, 20)

 P1 = (10, 15)

 P2 = (15, 15)

15 Prepared By Haftom B. 5/20/2022 16 Prepared By Haftom B. 5/20/2022


4. Reflection Clipping
 Reflection
 We can define clipping as removing portions of a picture that are outside of a
 A reflection is a transformation that produces a mirror image of an object.
specified region of space.
 The mirror image for a two-dimensional reflection is generated relative to an axis of  The most common use of clipping is to remove (parts of) primitives that are
reflection by rotating the object 1800 about the reflection axis. outside of the view volume of the virtual camera in the graphics pipeline.
 We can choose an axis of reflection in the xy plane or perpendicular to the xy plane.  The shape of the view volume will depend on the type of projection
 When the reflection axis is a line in the xy plane, the rotation path about this axis is in a plane transformation used, but always a number of clipping planes can define the
perpendicular to the xy plane. volume.

 For reflection axes that are perpendicular to the xy plane, the rotation path is in the xy plane.
 Reflection about the line y = 0, the x axis, is accomplished with the transformation matrix:

17 Prepared By Haftom B. 5/20/2022 18 Prepared By Haftom B. 5/20/2022

Cont.. Point Clipping


 There are three graphics elements involved in clipping algorithms:  Point clipping is the simplest of the algorithms that states a point P = (x, y) is
 Point Clipping visible only if:
 Line Clipping and 

 Area (polygon) Clipping 


 where (xmin, ymin) and (xmax, ymax) are diagonal coordinates of the drawing
window.
 If any one of these four inequalities is not satisfied, the point is clipped (not
saved for display).
 With point primitives there were only two possible outcomes of the clipping
process: accept or reject the point.

19 Prepared By Haftom B. 5/20/2022 20 Prepared By Haftom B. 5/20/2022


Line Clipping Cohen-Sutherland Line Clipping
 Usually drawings, including text and curves can be reduced to  Now we will consider a specific example of a line clipping algorithm: the
Cohen-Sutherland algorithm.
number of discrete small lines.  The general approach to clipping line primitives using this technique can be
 For the purpose of clipping, we have three types of lines. summarised as:
 Lines that are completely visible  Decide if we can accept the entire primitive without further processing (trivial accept)
 Decide if we can reject the entire primitive without further processing
 Lines that are completely invisible (trivial reject)
 Lines that are partially visible  Divide-and-conquer: for each clipping plane,
 Compute intersection of the line with the clipping plane
 Divide the line into two at the intersection point
 Perform a trivial reject on one part of the line
 Accept the other part of the line to be clipped by the other clipping plane(s)

21 Prepared By Haftom B. 5/20/2022 22 Prepared By Haftom B. 5/20/2022

5.2 3-D Transformation Cont..


1. Translation  If P is a point having co-ordinates in three directions (x, y, z) is translated, then
after translation its coordinates will be (x1 y1 z1) after translation.
 It is the movement of an object from one position to another
 Tx Ty Tz are translation vectors in x, y, and z directions respectively.
position.
• Three-dimensional
 Translation is done using translation vectors.
transformations are performed
 There are three vectors in 3D instead of two. by transforming each vertex of
 These vectors are in x, y, and z directions. the object.
• If an object has five corners,
 Translation in the x-direction is represented using Tx.
then the translation will be
 The translation is y-direction is represented using Ty. accomplished by translating all
 The translation in the z- direction is represented using Tz. five points to new locations.
23 Prepared By Haftom B. 5/20/2022 24 Prepared By Haftom B. 5/20/2022
Matrix Translation

25 Prepared By Haftom B. 5/20/2022 26 Prepared By Haftom B. 5/20/2022

Example 2 Cont..
 Problem-  For Coordinates A(0, 3, 1)
 Given a 3D object with coordinate points A(0, 3, 1), B(3, 3, 2), C(3, 0, 0), D(0,
 Let the new coordinates of A = (Xnew, Ynew, Znew).
0, 0). Apply the translation with the distance 1 towards X axis, 1 towards Y
axis and 2 towards Z axis and obtain the new coordinates of the object.  Applying the translation equations, we have-
 Xnew = Xold + Tx = 0 + 1 = 1
 Solution-  Ynew = Yold + Ty = 3 + 1 = 4
 Given-
 Znew = Zold + Tz = 1 + 2 = 3
 Old coordinates of the object = A (0, 3, 1), B(3, 3, 2), C(3, 0, 0), D(0, 0, 0)
 Translation vector = (Tx, Ty, Tz) = (1, 1, 2)  Thus, New coordinates of A = (1, 4, 3).

27 Prepared By Haftom B. 5/20/2022 28 Prepared By Haftom B. 5/20/2022


Cont.. Cont…
 For Coordinates B(3, 3, 2)  For Coordinates C(3, 0, 0)
 Let the new coordinates of B = (Xnew, Ynew, Znew).
 Let the new coordinates of C = (Xnew, Ynew, Znew).
 Applying the translation equations, we have-

 Xnew = Xold + Tx = 3 + 1 = 4  Applying the translation equations, we have-


 Ynew = Yold + Ty = 3 + 1 = 4  Xnew = Xold + Tx = 3 + 1 = 4
 Znew = Zold + Tz = 2 + 2 = 4
 Ynew = Yold + Ty = 0 + 1 = 1
 Znew = Zold + Tz = 0 + 2 = 2
 Thus, New coordinates of B = (4, 4, 4).
 Thus, New coordinates of C = (4, 1, 2).

29 Prepared By Haftom B. 5/20/2022 30 Prepared By Haftom B. 5/20/2022

Cont.. Cont..
 For Coordinates D(0, 0, 0)  Example: A point has coordinates in
the x, y, z direction i.e., (5, 6, 7).
 Let the new coordinates of D = (Xnew, Ynew, Znew).
 The translation is done in the x-
 Applying the translation equations, we have- direction by 3 coordinate and y
 Xnew = Xold + Tx = 0 + 1 = 1 direction.
 Three coordinates and in the z-
 Ynew = Yold + Ty = 0 + 1 = 1
direction by two coordinates.
 Znew = Zold + Tz = 0 + 2 = 2  Shift the object. Find coordinates of
 the new position.
 Thus, New coordinates of D = (1, 1, 2).

31 Prepared By Haftom B. 5/20/2022 32 Prepared By Haftom B. 5/20/2022


Cont.. 2. Scaling
 Scaling is used to change the size of an object.
 The size can be increased or decreased.
 The scaling three factors are required Sx Sy and Sz.]

 Sx= Scaling factor in x- direction


Sy= Scaling factor in y-direction
Sz= Scaling factor in z-direction

33 Prepared By Haftom B. 5/20/2022 34 Prepared By Haftom B. 5/20/2022

Cont.. Cont..
• steps performed when scaling of  Note: If all scaling factors Sx=Sy=Sz.Then scaling is
objects with fixed point (a, b, c). called as uniform Scaling.
 If scaling is done with different scaling vectors, it is called a
1. Translate fixed point to the origin differential scaling.
2. Scale the object relative to the origin
3. Translate object back to its original
position.

35 Prepared By Haftom B. 5/20/2022 36 Prepared By Haftom B. 5/20/2022


Example Cont..
 Problem-01:  Solution For Coordinates A(0, 3, 3)
 Given a 3D object with coordinate points A(0, 3, 3), B(3, 3, 6), C(3, 0, 1), D(0,  Let the new coordinates of A after scaling = (Xnew, Ynew, Znew).
0, 0).  Applying the scaling equations, we have-
 Apply the scaling parameter 2 towards X axis, 3 towards Y axis and 3 towards
 Xnew = Xold x Sx = 0 x 2 = 0
Z axis and obtain the new coordinates of the object.
 Ynew = Yold x Sy = 3 x 3 = 9
 Solution-
 Znew = Zold x Sz = 3 x 3 = 9
 Given-
 Old coordinates of the object = A (0, 3, 3), B(3, 3, 6), C(3, 0, 1), D(0, 0, 0)  Thus, New coordinates of corner A after scaling = (0, 9, 9).
 Scaling factor along X axis = 2
 Scaling factor along Y axis = 3
 Scaling factor along Z axis =3

37 Prepared By Haftom B. 5/20/2022 38 Prepared By Haftom B. 5/20/2022

Cont.. Cont..
 For Coordinates B(3, 3, 6)  For Coordinates C(3, 0, 1)
 Let the new coordinates of B after scaling = (Xnew, Ynew, Znew).  Let the new coordinates of C after scaling = (Xnew, Ynew,
 Applying the scaling equations, we have- Znew).
 Xnew = Xold x Sx = 3 x 2 = 6  Applying the scaling equations, we have-

 Ynew = Yold x Sy = 3 x 3 = 9  Xnew = Xold x Sx = 3 x 2 = 6


 Znew = Zold x Sz = 6 x 3 = 18  Ynew = Yold x Sy = 0 x 3 = 0
 Thus, New coordinates of corner B after scaling = (6, 9, 18).  Znew = Zold x Sz = 1 x 3 = 3
 Thus, New coordinates of corner C after scaling = (6, 0, 3).

39 Prepared By Haftom B. 5/20/2022  40 Prepared By Haftom B. 5/20/2022


Cont.. Rotation
 For Coordinates D(0, 0, 0)  It is moving of an object about an angle.
 Let the new coordinates of D after scaling = (Xnew, Ynew, Znew).  Movement can be anticlockwise or clockwise.
 Applying the scaling equations, we have-  3D rotation is complex as compared to the 2D rotation.
 For 2D we describe the angle of rotation, but for a 3D angle
 Xnew = Xold x Sx = 0 x 2 = 0 of rotation and axis of rotation are required.
 Ynew = Yold x Sy = 0 x 3 = 0
 There are 3 possible types of rotation-
 Znew = Zold x Sz = 0 x 3 = 0
 X-axis Rotation
 Thus, New coordinates of corner D after scaling = (0, 0, 0).
 Y-axis Rotation
 Z-axis Rotation

41 Prepared By Haftom B. 5/20/2022 42 Prepared By Haftom B. 5/20/2022

CONT… CONT…
 For Y-Axis Rotation-
 This rotation is achieved by using the following rotation equations-
 Xnew = Zold * sinθ + Xold * cosθ
 Ynew = Yold
 Znew = Yold * cosθ – Xold * Sinθ

43 Prepared By Haftom B. 5/20/2022 44 Prepared By Haftom B. 5/20/2022


Cont... Example
 For Z-Axis Rotation-  Problem-01:
 This rotation is achieved by using the following rotation equations-  Given a homogeneous point (1, 2, 3). Apply rotation 90 degree towards X, Y
 Xnew = Xold * cosθ – Yold*sinθ and Z axis and find out the new coordinate points.
 Ynew = Xold * sinθ + Yold *cosθ  Solution-
 Znew = Zold  Given-
 Old coordinates = (Xold,Yold, Zold) = (1, 2, 3)
 Rotation angle = θ = 90º

45 Prepared By Haftom B. 5/20/2022 46 Prepared By Haftom B. 5/20/2022

For X-Axis Rotation- For Y-Axis Rotation-


 Let the new coordinates after rotation = (Xnew, Ynew, Znew).  Let the new coordinates after rotation = (Xnew, Ynew, Znew).
 Applying the rotation equations, we have-
 Applying the rotation equations, we have-
 Xnew = Zold x sinθ + Xold x cosθ = 3 x sin90° + 1 x cos90° = 3 x 1 + 1 x 0 = 3
 Xnew = Xold = 1  Ynew = Yold = 2
 Ynew = Yold x cosθ – Zold x sinθ = 2 x cos90° – 3 x sin90° = 2 x 0 – 3 x 1 = -3  Znew = Yold x cosθ – Xold x sinθ = 2 x cos90° – 1 x sin90° = 2 x 0 – 1 x 1 = -1
 Znew = Yold x sinθ + Zold x cosθ = 2 x sin90° + 3 x cos90° = 2 x 1 + 3 x 0 = 2 
 Thus, New coordinates after rotation = (3, 2, -1).
 Thus, New coordinates after rotation = (1, -3, 2).

47 Prepared By Haftom B. 5/20/2022 48 Prepared By Haftom B. 5/20/2022


For Z-Axis Rotation- Combination of Transformations
 Let the new coordinates after rotation = (Xnew, Ynew, Znew).  A number of transformations or sequence of transformations can be
 Applying the rotation equations, we have- combined into single one called as composition.
 Xnew = Xold x cosθ – Yold x sinθ = 1 x cos90° – 2 x sin90° = 1 x 0 – 2 x 1 =  The resulting matrix is called as composite matrix. The process of
-2 combining is called as concatenation.
 Ynew = Xold x sinθ + Yold x cosθ = 1 x sin90° + 2 x cos90° = 1 x 1 + 2 x 0 =  Suppose we want to perform rotation about an arbitrary point, then
1 we can perform it by the sequence of three transformations
 Znew = Zold = 3 1.Translation
 2. Rotation
 Thus, New coordinates after rotation = (-2, 1, 3) 3. Scaling

49 Prepared By Haftom B. 5/20/2022 50 Prepared By Haftom B. 5/20/2022

Example

End of chapter 4

51 Prepared By Haftom B. 5/20/2022 52 Prepared By Haftom B. 5/20/2022

You might also like