CG Chap 5
CG Chap 5
CG Chap 5
2
1
Continue……..
In Matrix form, the above translation equations may be represented as
Problem:- Given a 3D object with coordinate points A(0, 3, 1), B(3, 3, 2),
C(3, 0, 0), D(0, 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.
Solution:-
Given 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)
Let the new coordinates of B = (Xnew, Ynew, Znew). Let the new coordinates of D = (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 = 0 + 1 = 1
• Znew = Zold + Tz = 2 + 2 = 4 • Ynew = Yold + Ty = 0 + 1 = 1
Thus, New coordinates of B = (4, 4, 4). • Znew = Zold + Tz = 0 + 2 = 2
Let the new coordinates of C = (Xnew, Ynew, Znew). Thus, New coordinates of the object = A (1, 4, 3), B(4, 4, 4), C(4, 1, 2),
Applying the translation equations, we have D(1, 1, 2).
• Xnew = Xold + Tx = 3 + 1 = 4
• Ynew = Yold + Ty = 0 + 1 = 1
• Znew = Zold + Tz = 0 + 2 = 2
Thus, New coordinates of C = (4, 1, 2). Continue……
7 8
3D Rotation in Computer Graphics This rotation is achieved by using the following rotation equations
In Computer graphics, 3D Rotation is a process of rotating an object • Xnew = Xold
with respect to an angle in a three dimensional plane. • Ynew = Yold x cosθ – Zold x sinθ
• Znew = Yold x sinθ + Zold x cosθ
Consider a point object O has to be rotated from one angle to another
in a 3D plane. In Matrix form, the above rotation equations may be represented as
Let-
• Initial coordinates of the object O = (Xold, Yold, Zold)
• Initial angle of the object O with respect to origin = Φ
• Rotation angle = θ
• New coordinates of the object O after rotation = (Xnew, Ynew, Znew)
• Z-axis Rotation
Continue………. Continue……… 10
Continue…….11 Continue…….
12
Problem-01: For Y-Axis Rotation-
Let the new coordinates after rotation = (Xnew, Ynew, Znew).
Given a homogeneous point (1, 2, 3). Apply rotation 90 degree towards X, Y and Z axis
and find out the new coordinate points. 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
Solution- • Ynew = Yold = 2
• Znew = Yold x cosθ – Xold x sinθ = 2 x cos90° – 1 x sin90° = 2 x 0 – 1 x 1 = -1
Given-
• Old coordinates = (Xold, Yold, Zold) = (1, 2, 3) Thus, New coordinates after rotation = (3, 2, -1).
• Rotation angle = θ = 90º
For Z-Axis Rotation-
For X-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 = Xold x cosθ – Yold x sinθ = 1 x cos90° – 2 x sin90° = 1 x 0 – 2 x 1 = -2
• Xnew = Xold = 1 • Ynew = Xold x sinθ + Yold x cosθ = 1 x sin90° + 2 x cos90° = 1 x 1 + 2 x 0 = 1
• Ynew = Yold x cosθ – Zold x sinθ = 2 x cos90° – 3 x sin90° = 2 x 0 – 3 x 1 = -3 • Znew = Zold = 3
• 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 = (-2, 1, 3).
Thus, New coordinates after rotation = (1, -3, 2). Continue……. 13 14
3D Scaling in Computer Graphics This scaling is achieved by using the following scaling equations-
In computer graphics, scaling is a process of modifying or altering the • Xnew = Xold x Sx
size of objects. • Ynew = Yold x Sy
• Scaling may be used to increase or reduce the size of object. • Znew = Zold x Sz
• Scaling subjects the coordinate points of the original object to change.
• Scaling factor determines whether the object size is to be increased or In Matrix form, the above scaling equations may be represented as
reduced.
• If scaling factor > 1, then the object size is increased.
• If scaling factor < 1, then the object size is reduced.
In Matrix form, the above reflection equations may be represented as In Matrix form, the above reflection equations may be represented as
21 22
Continue…….
23 24
Continue……. Continue…….
Shearing in Y Axis- Shearing in Z Axis-
Shearing in Y axis is achieved by using the following shearing equations-
• Xnew = Xold + Shx x Yold Shearing in Z axis is achieved by using the following shearing equations-
• Ynew = Yold • Xnew = Xold + Shx x Zold
• Znew = Zold + Shz x Yold • Ynew = Yold + Shy x Zold
• Znew = Zold
In Matrix form, the above shearing equations may be represented as
In Matrix form, the above shearing equations may be represented as
25 26
Continue…….
Continue……. Continue…….
Composite Transformation
• We can set up a matrix for any sequence of transformations as a
composite transformation matrix by calculating the matrix product of
individual transformation.
• For column matrix representation of coordinate positions, we form
composite transformations by multiplying matrices in order from
right to left.
29 30
Continue…….
31 32
Continue……. Continue…….
33 34
Continue……. Continue…….
35