2d 3d Problems
2d 3d Problems
We have discussed-
● Transformation is a process of modifying and re-positioning the existing
graphics.
● 3D Transformations take place in a three dimensional plane.
Advertisements
1. Translation
2. Rotation
3. Scaling
4. Reflection
5. Shear
Advertisements
In Computer graphics,
3D Shearing is an ideal technique to change the shape of an existing object in a three dimensional plane.
Advertisements
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
Advertisements
Consider a point object O has to be sheared in a 3D plane.
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 = (Xnew, Ynew, Znew)
Shearing in X Axis-
● Xnew = Xold
● Ynew = Yold + Shy x Xold
● Znew = Zold + Shz x Xold
Advertisements
Shearing in Y Axis-
×
Advertisements
Shearing in Z Axis-
Advertisements
Problem-01:
Advertisements
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-
Advertisements
Given-
● Old corner coordinates of the triangle = A (0, 0, 0), B(1, 1, 2), C(1, 1, 3)
Shearing in X Axis-
Let the new coordinates of corner A after shearing = (Xnew, Ynew, Znew).
Let the new coordinates of corner B after shearing = (Xnew, Ynew, Znew).
×
Advertisements
Advertisements
Let the new coordinates of corner C after shearing = (Xnew, Ynew, Znew).
● Xnew = Xold = 1
● Ynew = Yold + Shy x Xold = 1 + 2 x 1 = 3
● Znew = Zold + Shz x Xold = 3 + 3 x 1 = 6
Shearing in Y Axis-
Let the new coordinates of corner A after shearing = (Xnew, Ynew, Znew).
Advertisements
Let the new coordinates of corner B after shearing = (Xnew, Ynew, Znew).
Let the new coordinates of corner C after shearing = (Xnew, Ynew, Znew).
Advertisements
Advertisements
Shearing in Z Axis-
Let the new coordinates of corner A after shearing = (Xnew, Ynew, Znew).
s
Let the new coordinates of corner B after shearing = (Xnew, Ynew, Znew).
Advertisements
Let the new coordinates of corner C after shearing = (Xnew, Ynew, Znew).
Advertisements
We have discussed-
● Transformation is a process of modifying and re-positioning the existing
graphics.
● 3D Transformations take place in a three dimensional plane.
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 B after reflection = (Xnew, Ynew, Znew).
Let the new coordinates of corner C after reflection = (Xnew, Ynew, Znew).
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 = (Xnew, Ynew, Znew).
Let the new coordinates of corner C after reflection = (Xnew, Ynew, Znew).
We have discussed-
● Transformation is a process of modifying and re-positioning the existing
graphics.
● 3D Transformations take place in a three dimensional plane.
1. Translation
2. Rotation
3. Scaling
4. Reflection
5. Shear
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 = (Xnew, 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
We have discussed-
● Transformation is a process of modifying and re-positioning the existing
graphics.
● 3D Transformations take place in a three dimensional plane.
1. Translation
2. Rotation
3. Scaling
4. Reflection
5. Shear
In Computer graphics,
3D Rotation is a process of rotating an object with respect to an angle in a three dimensional plane.
Consider a point object O has to be rotated from one angle to another in a 3D plane.
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)
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º
In Computer graphics,
Transformation is a process of modifying and re-positioning the existing graphics.
Transformation Techniques-
In computer graphics, various transformation techniques are-
1. Translation
2. Rotation
3. Scaling
4. Reflection
5. Shear
In Computer graphics,
3D Translation is a process of moving an object from one position to another in a three dimensional plane.
Consider a point object O has to be moved from one position to another in a 3D plane.
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)
This translation is achieved by adding the translation coordinates to the old coordinates
of the object as-
● Xnew = Xold + Tx (This denotes translation towards X axis)
● Ynew = Yold + Ty (This denotes translation towards Y axis)
● Znew = Zold + Tz (This denotes translation towards Z axis)
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)
We have discussed-
● Transformation is a process of modifying and re-positioning the existing
graphics.
● 2D Transformations take place in a two dimensional plane.
1. Translation
2. Rotation
3. Scaling
4. Reflection
5. Shear
In Computer graphics,
2D Shearing is an ideal technique to change the shape of an existing object in a two dimensional plane.
Advertisements
In a two dimensional plane, the object size can be changed along X direction as well as
Y direction.
So, there are two versions of shearing-
1. Shearing in X direction
2. Shearing in Y direction
Advertisements
Consider a point object O has to be sheared in a 2D plane.
Let-
Advertisements
Shearing in X Axis-
Advertisements
In Matrix form, the above shearing equations may be represented as-
For homogeneous coordinates, the above shearing matrix may be represented as a 3 x
3 matrix as-
Advertisements
Problem-01:
Given a triangle with points (1, 1), (0, 0) and (1, 0). Apply shear parameter 2 on X axis
and 2 on Y axis and find out the new coordinates of the object.
Advertisements
Solution-
Given-
● Old corner coordinates of the triangle = A (1, 1), B(0, 0), C(1, 0)
● Shearing parameter towards X direction (Shx) = 2
● Shearing parameter towards Y direction (Shy) = 2
Shearing in X Axis-
Advertisements
s
Applying the shearing equations, we have-
● Xnew = Xold + Shx x Yold = 1 + 2 x 0 = 1
● Ynew = Yold = 0
Thus, New coordinates of the triangle after shearing in X axis = A (3, 1), B(0, 0), C(1, 0).
Shearing in Y Axis-
Advertisements
For Coordinates A(1, 1)
s
Applying the shearing equations, we have-
● Xnew = Xold = 1
● Ynew = Yold + Shy x Xold = 1 + 2 x 1 = 3
Advertisements
We have discussed-
● Transformation is a process of modifying and re-positioning the existing
graphics.
● 2D Transformations take place in a two dimensional plane.
Let-
● Initial coordinates of the object O = (Xold, Yold)
● New coordinates of the reflected object O after reflection = (Xnew, Ynew)
Reflection On X-Axis:
Reflection On Y-Axis:
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.
Solution-
Given-
● Old corner coordinates of the triangle = A (3, 4), B(6, 4), C(5, 6)
● Reflection has to be taken on the X axis
Thus, New coordinates of the triangle after reflection = A (3, -4), B(6, -4), C(5, -6).
Problem-02:
Given a triangle with coordinate points A(3, 4), B(6, 4), C(5, 6). Apply the reflection on
the Y axis and obtain the new coordinates of the object.
Solution-
Given-
● Old corner coordinates of the triangle = A (3, 4), B(6, 4), C(5, 6)
● Reflection has to be taken on the Y axis
Thus, New coordinates of the triangle after reflection = A (-3, 4), B(-6, 4), C(-5, 6).
We have discussed-
● Transformation is a process of modifying and re-positioning the existing
graphics.
● 2D Transformations take place in a two dimensional plane.
1. Translation
2. Rotation
3. Scaling
4. Reflection
5. Shear
Let-
● Initial coordinates of the object O = (Xold, Yold)
● Scaling factor for X-axis = Sx
● Scaling factor for Y-axis = Sy
● New coordinates of the object O after scaling = (Xnew, Ynew)
Problem-01:
Given a square object with coordinate points A(0, 3), B(3, 3), C(3, 0), D(0, 0). Apply the
scaling parameter 2 towards X axis and 3 towards Y axis and obtain the new
coordinates of the object.
Solution-
Given-
● Old corner coordinates of the square = A (0, 3), B(3, 3), C(3, 0), D(0, 0)
● Scaling factor along X axis = 2
● Scaling factor along Y axis = 3
Thus, New coordinates of the square after scaling = A (0, 9), B(6, 9), C(6, 0), D(0, 0).
To gain better understanding about 2D Scaling in Computer Graphics,
Watch this Video Lecture
We have discussed-
● Transformation is a process of modifying and re-positioning the existing
graphics.
● 2D Transformations take place in a two dimensional plane.
In computer graphics, various transformation techniques are-
1. Translation
2. Rotation
3. Scaling
4. Reflection
5. Shear
In Computer graphics,
2D Rotation is a process of rotating an object with respect to an angle in a two dimensional plane.
Consider a point object O has to be rotated from one angle to another in a 2D plane.
Let-
● Initial coordinates of the object O = (Xold, Yold)
● Initial angle of the object O with respect to origin = Φ
● Rotation angle = θ
● New coordinates of the object O after rotation = (Xnew, Ynew)
Problem-01:
Given a line segment with starting point as (0, 0) and ending point as (4, 4). Apply 30
degree rotation anticlockwise direction on the line segment and find out the new
coordinates of the line.
Solution-
We rotate a straight line by its end points with the same angle. Then, we re-draw a line
between the new end points.
Given-
● Old ending coordinates of the line = (Xold, Yold) = (4, 4)
● Rotation angle = θ = 30º
Let new ending coordinates of the line after rotation = (Xnew, Ynew).
Xnew
= Xold x cosθ – Yold x sinθ
= 4 x cos30º – 4 x sin30º
= 4 x (√3 / 2) – 4 x (1 / 2)
= 2√3 – 2
= 2(√3 – 1)
= 2(1.73 – 1)
= 1.46
Ynew
= Xold x sinθ + Yold x cosθ
= 4 x sin30º + 4 x cos30º
= 4 x (1 / 2) + 4 x (√3 / 2)
= 2 + 2√3
= 2(1 + √3)
= 2(1 + 1.73)
= 5.46
Thus, New ending coordinates of the line after rotation = (1.46, 5.46).
Alternatively,
In matrix form, the new ending coordinates of the line after rotation may be obtained as-
Thus, New ending coordinates of the line after rotation = (1.46, 5.46).
Problem-02:
Given a triangle with corner coordinates (0, 0), (1, 0) and (1, 1). Rotate the triangle by
90 degree anticlockwise direction and find out the new coordinates.
Solution-
We rotate a polygon by rotating each vertex of it with the same rotation angle.
Given-
● Old corner coordinates of the triangle = A (0, 0), B(1, 0), C(1, 1)
● Rotation angle = θ = 90º
Xnew
= Xold x cosθ – Yold x sinθ
= 0 x cos90º – 0 x sin90º
=0
Ynew
= Xold x sinθ + Yold x cosθ
= 0 x sin90º + 0 x cos90º
=0
Xnew
= Xold x cosθ – Yold x sinθ
= 1 x cos90º – 0 x sin90º
=0
Ynew
= Xold x sinθ + Yold x cosθ
= 1 x sin90º + 0 x cos90º
=1+0
Advertisements
=1
Xnew
= Xold x cosθ – Yold x sinθ
= 1 x cos90º – 1 x sin90º
=0–1
= -1
Advertisements
Ynew
= Xold x sinθ + Yold x cosθ
= 1 x sin90º + 1 x cos90º
=1+0
=1
Advertisements
Advertisements
Thus, New coordinates of the triangle after rotation = A (0, 0), B(0, 1), C(-1, 1).
Advertisements
In Computer graphics,
Transformation is a process of modifying and re-positioning the existing graphics.
Transformation Techniques-
In Computer graphics,
2D Translation is a process of moving an object from one position to another in a two dimensional plane.
Consider a point object O has to be moved from one position to another in a 2D plane.
Let-
● Initial coordinates of the object O = (Xold, Yold)
● New coordinates of the object O after translation = (Xnew, Ynew)
● Translation vector or Shift vector = (Tx, Ty)
This translation is achieved by adding the translation coordinates to the old coordinates
of the object as-
● Xnew = Xold + Tx (This denotes translation towards X axis)
● Ynew = Yold + Ty (This denotes translation towards Y axis)
Given a circle C with radius 10 and center coordinates (1, 4). Apply the translation with
distance 5 towards X axis and 1 towards Y axis. Obtain the new coordinates of C
without changing its radius.
Solution-
Given-
● Old center coordinates of C = (Xold, Yold) = (1, 4)
● Translation vector = (Tx, Ty) = (5, 1)
Alternatively,
In matrix form, the new center coordinates of C after translation may be obtained as-
Thus, New center coordinates of C = (6, 5).
Problem-02:
Given a square with coordinate points A(0, 3), B(3, 3), C(3, 0), D(0, 0). Apply the
translation with distance 1 towards X axis and 1 towards Y axis. Obtain the new
coordinates of the square.
Solution-
Given-
● Old coordinates of the square = A (0, 3), B(3, 3), C(3, 0), D(0, 0)
● Translation vector = (Tx, Ty) = (1, 1)