0% found this document useful (0 votes)
31 views

3D Transformation

Transformation 3d

Uploaded by

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

3D Transformation

Transformation 3d

Uploaded by

khushiisaha2020
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 47
3D Transformation in Computer Graphics— 4 3D Transformations take place in a three dimensional plane. & 3D Transformations ore important and a bit more complex than 2D Transformations. & Transformations are helpful in changing the position, size, orientation, shape ete of the object. In computer graphics, various transformation techniques are~ Translation Rotation Sealing Reflection Shear gsene Translation It is the movement of en object from one position to another position. Translation is dene using translation vectors. There are three vectors in 3D instead of two. These vectors are in x, y, and z directions. Translation in the x- direction is represented using T.. The translation is y-direction is represented using Ty. The translation in the z- direction is represented using T:. Tf P is a point having co-ordinates in three directions (x, y, 2) is translated, then after translation its coordinates will be (x y z) after translation. Tx Ty Tzare translation vectors in x, y, and z directions respectively. Xext Tr Three-dimensional transformations are performed by transforming each vertex of the object. If an object has five comners, then the translation will be accomplished by translating all five points to new locations. Y axis Sy oyiZ) oayz) X axis Z axis Z axis Matrix for translation Matrix representation of point translation Point shown in fig is (x, y, z). It become (x'y.z) after translation. Tx Ty Ts are translation vector. vy] fl 0 0 Tym ly|_fo 1 0 lly Z|" Jo o 1 |e 1 oo ill has coordinates in the x, y, 2 direction ie., (5,6, 7). The translation is done in the x-direction by 3 coordinate and y direction, Three coordinates and in the 2- direction by two coordinates. Shift the object. Find coordinates of the new position. Solution: Co-ordinate of the point ore (5, 6,7) Translation vector in x direction = 3 Translation vector in y direction Translation vector in z direction = 2 Translation matrix is 1 0 00 o 100 oo180 hm T% 1 ‘Multiply co-ordinates of point with translation matrix (ety'2) = (667.1) (1 0 0 0 0100 oo10 3324 = [B10+0+3, O+6+0+3, O+0+7+2, O+0+0+1] = [899 1] x becomes x!=8 y becomes y'=9 z becomes 2'=9 Example: Given @ 3D object with coordinate points A(0, 3, 1), 8G, 3, 2), C(3, 0, 0), D(O, 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. 3D Rotation in Computer Graphics— Consider a point object O has to be rotated from one angle to another ina 3D plane. Let Initial coordinates of the object O = (Xe, Yo, Zot) Initial angle of the object O with respect to origin = & Rotation angle = © New coordinates of the object O after rotation = (Xraw. Yeew. Zao) In3 dimensions, there ore 3 possible types of rotation- + X-axis Rotation + Y-axis Rotation + Z-axis Rotation For X-Axis Rotation- This rotation is achieved by using the following rotation equations- Xen = Kats + Yron = Yous x c058 ~ Zats x sin © Zoww = Yas x sin + Zag x cos In Matrix form, the above rotation equations may be represented as- 0 0 cos6 = -sin@ sind = cos® 0 0 3D Rotation Matrix (For X-Axis Rotation) For Y-Axis Rotation- This rotatio is achieved by using the following rotation equations- + Xeon # Zoi x sin@ * Xa x €056 © Youn = Yate + Zon = Vai x 6058 ~ Xs x sin In Matrix form, the above rotation equations may be represented as- Oo 1 0 0 3D Rotation Matrix (For Y-Axis Rotation) For Z-Axis Rotation- This rotation is achieved by using the following rotation equations- + ron = Kats x C058 = Yate X sin + Yaon = Xaa x sin # Yous x cos + Zoe? Zao In Matrix form, the above rotation equations may be represented as~ 0 0 0 0 1 0 3D Rotation Matrix (For Z-Axis Rotation) Problem-01: Given a homogeneous point (1, 2, 3). Apply rotation 90 degree towards X, Y and. Z axis and find out the new coordinate points. Solution- Let the new coordinates after rotation = (Xoew, Youn, Zreu). Applying the rotation equations, we have- © Xow? Xe = + Yon = Yois x C058 = Zas x si + Zo? Yes X sin@ + Zs x cos8 = 2 x x c0590° ~ 3 x sin90* 190° +3 x c0s90" Thus, New coordinates after rotation = (1, -3, 2). For Y-Axis Rotation- Let the new coordinates after rotation = (Xnew, Yrew, Znew) Applying the rotation equations, we have- + Xnoe # Zats x sin + Xai x C098 = 3 x sinQO? +1 x cos90"= 3x141xO=3 © Yon = Yas = 2 + Zoo? Ye X C088 ~ ou x sin = 2 x cos90? - 1 x sin90°= 2 xO-1xt Thus, New coordinates after rotation = (3, 2, -1). For Z-Axis Rotation- Let the new coordinates after rotation = (Xnew, Y: Applying the rotation equations, we have- © Xeow = Xets x €086 = Yai x sin6 = 1 x cos90" = 2 x sin80* xO-2x12-2 Yon = Xia x sin + Yas x cos® = 1x sin90" +2 x cos90P=1x1+2xO=1 © Zo = Zag = Thus, New coordinates after rotation = (-2, 1, 3). 3D Reflection in Computer Graphics + Reflection is @ kind of rotation where the ongle of rotation is 180 degree. + The reflected object is always formed on the other side of mirror. + The size of reflected object is same as the size of original object. Consider a point object O has to be reflected ina 3D plone. Let- + Initial coordinates of the object O = (Xe, Yous, Zotd) + New coordinates of the reflected object O after reflection = (Xnew, Ynen Zen) Reflection Relative to XY Plane: This reflection is achieved by using the following reflection equations~ © Xoew = Kats In Matrix form, the above reflection equations may be represented as- 3D Reflection Matrix (Reflection Relative to XY plane) Reflection Relative to YZ Plane: This reflection is achieved by using the following reflection equations- + Xen = Kas = Yoon = Yous + Zoew = Zao In Matrix form, the above reflection equations may be represented as- 3D Reflection Matrix (Reflection Relative to YZ plane) This reflection is achieved by using the following reflection equations- + Krew = Kes © Yoon = “Yok + Zoe? Zoe In Matrix form, the above reflection equations may be represented as- 3D Reflection Matrix (Reflection Relative to XZ plane) Problem-O1: Given a 3D triangle with coordinate points A(3, 4, 1), B(6, 4. 2). C(5, 6. 3). Apply the reflection on the XY plane and find out the new coordinates of the object. Solution- Given- + Old comer coordinates of the triangle = A (3, 4,1),8(6, 4,2), (5,6, 3) ‘+ Reflection has to be taken on the XY plane For Coordinates A(3, 4, 1) Let the new coordinates of corner A after reflection = (Xnew, Yeews Znen)- Applying the reflection equations, we have- Thus, New coordinates of corner A after reflection = (3, 4, -1). Fi 4.2 Let the new coordinates of corner B after reflection = (Xnew, Yrew, Znen) Applying the reflection equations, we have- © Xow? Xets 6 For Coordinates 6, 3 Let the new coordinates of corner C after reflection = (Xrew, Yaew, Znew) Applying the reflection equations, we have~ © Xoo? Xe #5 © Yon ® Yas = 6 Thus, New coordinates of corner C after reflection = (5, 6, -3). Thus, New coordinates of the triangle after reflection = A (3, 4, -1), B(6, 4, -2), C6. 6.-3) Given a 3D triangle with coordinate points A(3, 4,1), 8(6, 4, 2), C(5, 6, 3). Apply the reflection on the XZ plane ond find out the new coordinates of the object + Old conner coordinates of the triangle = A (3, 4,1), 8(6, 4, 2),C(5,6,3) + Reflection has to be taken on the XZ plane Let the new coordinates of corner A after reflection = (Xnew, Yoew, Znew) Applying the reflection equations, we have- Thus, New coordinates of corner A after reflection = (3, -4,1). Let the new coordinates of corner B after reflection = (Xrew. Yrow. Znen). Applying the reflection equations, we have- For Coordinates C(5, 6, 3 Let the new coordinates of corner C after reflection = (Xrew, Yaew, Znew) Applying the reflection equations, we have~ + Xeon # Math # © Yoon ‘Thus, New coordinates of corner C after reflection = (5, -6, 3). ‘Thus, New coordinates of the triangle after reflection = A (3, CG, -6,3) 1), B(6, -4, 2), 3D Scaling in Computer Graphi + Scaling may be used to increase or reduce the size of object. + Scaling subjects the coordinate points of the original object to change. + Scaling factor determines whether the object size is to be increased or reduced. + If scaling factor > 1, then the object size is increased. + If scaling factor < 1, then the object size is reduced Consider a point object O has to be scaled in a 3D plane. Let- + Initial coordinates of the object O = (Xats, You Zots) + Scaling factor for X-oxis = Sx + Scaling factor for Y-axis = Sy + Scaling factor for Z-axis = Sz + New coordinates of the object O after sc This scaling is echieved by using the following scaling equations~ © Xnew = Xold x Sx + Yoon = Yotd X Sy © Znew = Zoid x Sz In Matrix form, the above scaling equations may be represented as- z, Se op a 0 Sy 0 0 0 Ss. 0 0 3D Scaling Matrix Problem-O1 Given a 3D object with coordinate points A(0, 3, 3), B(3, 3, 6), €(3, 0,1), B(0, 0, 0). Apply the scaling parameter 2 towards X axis, 3 towards Y axis and 3 towards Z axis and obtain the new coordinates of the object. Solution= Given- + Old coordinates of the object = A (0, 3, 3),B(3, 3,6), (3,0, 1), D1, 0, 0) + Scaling factor along X axis = 2 + Scaling factor along Y axis = 3 + Scaling factor along Z oxis = 3 3,3) Let the new coordinates of A after scaling = (Xnew, Ynew, Znew): Applying the scaling equations, we have- + Zoen = Zoi x S22 3x 3=9 Thus, New coordinates of corner A after scaling = (0,9, 9). Let the new coordinates of B after scaling = (Xnew, Ynew, Znew) Applying the scaling equations, we have- + Xnow = Xold x Set 3 x 226 + Yoon # Yau x Sy 23x © Zoen = Zo x S226 x35 18 Thus, New coordinates of corner B after scaling = (6,9, 18). Let the new coordinates of C after sealing = (Xnew, Ynew, Zaew). Applying the scaling equations, we have- © Xnew = Xo x Sx= 3 x 226 + Ynew = Yau x $/2 Ox3=0 + Zoow = Zoid x Sz = 1x Thus, New coordinates of corner C after scaling = (6, 0, 3). For Coordinates D(0, 0, 0) Let the new coordinates of D after scaling = (Xrew, Ynen, Znem): Applying the scaling equations, we have- + Xnow = Xeld x Sx 0 x 220 + Yoon ® Yad x Sy = 0x © Zoe = Zou x S22 0x 3=0 Thus, New coordinates of corner D after scaling = (0,0, 0) 3D Shearing in Computer Graphic: Ina three dimensional plane, the object size can be changed along X direction, ¥ direction as well os Z direction, So, there ere three versions of shearing- 1. Shearing in X direction 2, Shearing in¥ dinection 3. Shearing inZ direction Consider a point object O has to be sheared in « 3D plane. Let- + Initial coordinates of the object O = (Xe, Yo, Zot) + Shearing parameter towards X direction = She + Shearing parameter towards Y direction = Shy + Shearing parameter towards Z direction = Shz + New coordinates of the object O after shearing = (Kien, Yoon Zee) Shearing in X Axis- ‘Shearing in X axis is achieved by using the following shearing equations- + Keen = Ket + Yoew # Yast * Shy x Xa + Zoew = Zad + Shz x Xed In Matrix form, the above shearing equations may be represented as- 0 3D Shearing Matrix (in X axis) Shearing in Y Axis- ‘Shearing in Y axis is achieved by using the following shearing equations- Xeon = Xe She x Ves In Matrix form, the above shearing equations may be represented as- 3D Shearing Matrix (in ¥ axis) Shearing in Z_Axis- ‘Shearing in Z axis is achieved by using the following shearing equations + Xeew = Xa # Shy x Za + Yaoe = Yat * Shy x Za + Zoee? Zs In Matrix form, the above shearing equations may be represented as- shy Shy 0 1 0 1 0 ‘3D Shearing Matrix (In Z axis) Given a 3D triangle with points (0, 0, 0), (1,1, 2) and (1, 1, 3). Apply shear parameter 2 on X axis, 2 on ¥ axis and 3 on Z axis and find out the new coordinates of the object ‘Solution— Given- Old comer coordinates of the triangle = A (0,0, 0), 8(1, 1,2), C(t, 1, 3) ‘Shearing parameter towards X direction (Shs) = 2 ‘Shearing parameter towards ¥ direction (Shy) = 2 ‘Shearing parameter towards Y direction (Sh:) = 3 Shearing in X_ Axi For Coordinates A(O, 0, 0) Let the new coordinates of comner A after shearing = (Xnew, Yoew, Zac) Applying the shearing equations, we have~ © Xow = Xats =O + Ynon # Yous * Shy x Xap O# 2X0 =O © Zien = Zs # She x Xas = 043x020 Thus, New coordinates of corner A after shearing = (0, 0, 0) Let the new coordinates of corner B after shearing = (Xrew, Ynew, Znew) Applying the shearing equations, we have~ Xeon Kets = 1 Yoon = Yat * Shy x X= 1+ 2x13 + Zoe? Zats* She x Xa 243x125 Thus, New coordinates of corner B after shearing = (1, 3, 5). Let the new coordinates of corner C after shearing = (Xrem, Yew, Zren): Applying the shearing equations, we have~ © Xooe Xe = 1 © Yon = Yass * Shy x Xa © Zoe? Zaa + She x Xe +2x123 +3x126 Thus, New coordinates of corner € after shearing = (1, 3, 6). Thus, New coordinates of the triangle after shearing in X axis = A (0,0, 0), B(1, 3,5), C(t, 3, 6). Shearing in Y Axis- For Coordinates A(O, 0, 0) Let the new coordinates of corner A after shearing = (Xnew, Ynew, Zneu)- Applying the shearing equations, we have~ + Xow = Kats + She x Yois 2 O+ 2X 020 + Yaon = You = 0 © Zoo = Za + She x Yas +3%0=0 Thus, New coordinates of corner A after shearing = (0, 0, 0) For Coordinates B(1, 1, 2) Let the new coordinates of corner B after shearing = (Xrew, Ynew, Zeon) Applying the shearing equations, we have~ + Xow = Xous + Shicx Your 1+ 2x 123 + Yoon = Yas = Zoo Zas+ She x Yous = +3xds5 Thus, New coordinates of corner B after shearing = (3, 1,5). 14 Let the new coordinates of corner C after shearing = (Xnem, Yow, Zne Applying the shearing equations, we have~ + Koen = Kets # She x You = 142 x1 E 3 © Yoon # Yas = © Zoe # Zia # She x Vad 2 343x126 Thus, New coordinates of corner C after shearing = (3. 1, 6). Thus, New coordinates of the triangle after shearing in ¥ 1,5), (3, 1,6). A(0,0,0), 83, Shearing in Z Axis- For Coordinates A(O, 0, 0) Let the new coordinates of corner A after shearing = (Xnew, Ynew, Znew) Applying the shearing equations, we have- 42x +2x020 Thus, New coordinates of corner A after shearing = (0,0, 0) Let the new coordinates of corner B after shearing = (Xrew, Ynew, Znew). ‘Applying the shearing equations, we have + Xoo # Xa + She x Za 142 x2 25 © Ynon = You * Shy x Zags 142x225 + Zoe? Zas® 2 Thus, New coordinates of corner B after shearing = (5,5, 2). For Coordinates C(1, 1, 3 Let the new coordinates of corner C after shearing = (Xrew, Yew, Znew): ‘Applying the shearing equations, we have- +2x327 +2x37 Thus, New coordinates of corner C after shearing = (7, 7, 3). Thus, New coordinates of the triangle after shearing in Z axis = 5,2). €(7,7. 3). A(0,0,0), 865,

You might also like