3D Transformation in Computer Graphics
3D Transformation in Computer Graphics
Let-
Initial coordinates of the object O = (Xold, Yold, Zold)
New coordinates of the object O after translation = (Xnew, Ynew, Zold)
Translation vector or Shift vector = (Tx, Ty, Tz)
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-
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 = (X new, Ynew, Znew)
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-
Given-
Old coordinates = (Xold, Yold, Zold) = (1, 2, 3)
Rotation angle = θ = 90º
Let-
Initial coordinates of the object O = (Xold, Yold,Zold)
Scaling factor for X-axis = Sx
Scaling factor for Y-axis = Sy
Scaling factor for Z-axis = Sz
New coordinates of the object O after scaling = (X new, Ynew, Znew)
Problem-01:
Given a 3D object with coordinate points A(0, 3, 3), B(3, 3, 6), C(3, 0, 1), D(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), C(3, 0, 1), D(0, 0, 0)
Scaling factor along X axis = 2
Scaling factor along Y axis = 3
Scaling factor along Z axis = 3
For Coordinates A(0, 3, 3)
Let-
Initial coordinates of the object O = (Xold, Yold, Zold)
New coordinates of the reflected object O after reflection = (X new, Ynew,Znew)
In 3 dimensions, there are 3 possible types of reflection-
Problem-01:
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 corner coordinates of the triangle = A (3, 4, 1), B(6, 4, 2), C(5, 6, 3)
Reflection has to be taken on the XY plane
Let the new coordinates of corner A after reflection = (X new, Ynew, Znew).
Let the new coordinates of corner B after reflection = (X new, Ynew, Znew).
Let the new coordinates of corner C after reflection = (X new, Ynew, Znew).
Applying the reflection equations, we have-
Xnew = Xold = 5
Ynew = Yold = 6
Znew = -Zold = -3
Problem-02:
Given a 3D triangle with coordinate points A(3, 4, 1), B(6, 4, 2), C(5, 6, 3). Apply
the reflection on the XZ plane and find out the new coordinates of the object.
Solution-
Given-
Old corner coordinates of the triangle = A (3, 4, 1), B(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 = (X new, Ynew, Znew).
Let the new coordinates of corner B after reflection = (X new, Ynew, Znew).
Let the new coordinates of corner C after reflection = (X new, Ynew, Znew).
In a three dimensional plane, the object size can be changed along X direction, Y
direction as well as Z direction.
So, there are three versions of shearing-
1. Shearing in X direction
2. Shearing in Y direction
3. Shearing in Z direction
Let-
Initial coordinates of the object O = (Xold, Yold, Zold)
Shearing parameter towards X direction = Shx
Shearing parameter towards Y direction = Shy
Shearing parameter towards Z direction = Shz
New coordinates of the object O after shearing = (X new, Ynew, Znew)
Shearing in X Axis-
Shearing in X axis is achieved by using the following shearing equations-
Xnew = Xold
Ynew = Yold + Shy x Xold
Znew = Zold + Shz x Xold
Shearing in Y Axis-
Problem-01:
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 Y axis and 3 on Z axis and find out the new
coordinates of the object.
Solution-
Given-
Old corner coordinates of the triangle = A (0, 0, 0), B(1, 1, 2), C(1, 1, 3)
Shearing parameter towards X direction (Shx) = 2
Shearing parameter towards Y direction (Shy) = 2
Shearing parameter towards Y direction (Shz) = 3
Shearing in X Axis-
Let the new coordinates of corner A after shearing = (X new, Ynew, Znew).
Let the new coordinates of corner B after shearing = (X new, Ynew, Znew).
Let the new coordinates of corner C after shearing = (X new, Ynew, Znew).
Shearing in Y Axis-
For Coordinates A(0, 0, 0)
Let the new coordinates of corner A after shearing = (X new, Ynew, Znew).
Let the new coordinates of corner B after shearing = (X new, Ynew, Znew).
Let the new coordinates of corner C after shearing = (X new, Ynew, Znew).
Shearing in Z Axis-
Let the new coordinates of corner A after shearing = (X new, Ynew, Znew).
Let the new coordinates of corner B after shearing = (X new, Ynew, Znew).
Let the new coordinates of corner C after shearing = (X new, Ynew, Znew).