2D Transformation: Prepared By-Deep Tank (160110116052) Kishan Thakur (160110116054) Harshal Dankhara (160110116064)
2D Transformation: Prepared By-Deep Tank (160110116052) Kishan Thakur (160110116054) Harshal Dankhara (160110116064)
2D Transformation: Prepared By-Deep Tank (160110116052) Kishan Thakur (160110116054) Harshal Dankhara (160110116064)
Prepared by-
Deep Tank(160110116052)
Kishan Thakur(160110116054)
Harshal Dankhara(160110116064)
2D Transformation
What is Transformation ?
• Transformation means changing some graphics into something else by
applying rules. We can have various types of transformations such as
translation, scaling up or down, rotation, shearing etc. When a
transformation takes place on a 2D plane, it is called 2D
transformation.
• Transformations play an important role in computer graphics to
reposition the graphics on the screen and change their size or
orientation.
2D Transformation
Homogenous Coordinates
• To perform a sequence of transformation such as translation followed
by rotation and scaling, we need to follow a sequential process −
- Translate the coordinates,
- Rotate the translated coordinates, and then
- Scale the rotated coordinates to complete the composite
transformation.
2D Transformation
Homogenous Coordinates
• To shorten this process, we have to use 3×3 transformation matrix
instead of 2×2 transformation matrix. To convert a 2×2 matrix to 3×3
matrix, we have to add an extra dummy coordinate W.
• In this way, we can represent the point by 3 numbers instead of 2
numbers, which is called Homogenous Coordinate system. In this
system, we can represent all the transformation equations in matrix
multiplication. Any Cartesian point PX, Y can be converted to
homogenous coordinates by P’ (Xh, Yh, h).
2D Transformation
Translation
• A translation moves an object to a different position on the screen.
You can translate a point in 2D by adding translation coordinate (tx,
ty) to the original coordinate X, Y to get the new coordinate X ′, Y′.
2D Transformation
Translation
2D Transformation
Translation
• From the above figure, you can write that −
X’ = X + tx
Y’ = Y + ty
• The pair (tx, ty) is called the translation vector or shift vector.
• The above equations can also be represented using the column
vectors.
P' P T, with
x' x tx
P ' , P and T
y' y ty
2D Transformation
Rotation
2D Transformation
What is rotation
• In rotation, we rotate the object at particular angle θ (theta) from its
origin. From the following figure, we can see that the point P(X, Y) is
located at angle φ from the horizontal X coordinate with distance r
from the origin.
• Let us suppose you want to rotate it at the angle θ. After rotating it to
a new location, you will get a new point P’ (X’, Y’).
2D Transformation
x′=rcos(ϕ+θ)=rcosϕcosθ−rsinϕsinθ .......(3)
y′=rsin(ϕ+θ)=rcosϕsinθ+rsinϕcosθ .......(4)
Substituting equation (1) & (2) in (3) & (4) respectively, we will get
x′=xcosθ−ysinθ
y′=xsinθ+ycosθ
2D Transformation
• Let us assume that the original coordinates are (X, Y), the scaling
factors are (SX, SY), and the produced coordinates are (X’, Y’). This can
be mathematically represented as shown below −
X' = X . SX and Y' = Y . SY
2D Transformation
If we provide values less than 1 to the scaling factor S, then we can reduce the size of the object. If we
provide values greater than 1, then we can increase the size of the object.