2 D Transformation in Computer Graphics
Scaling
A scaling transformation alters size of an
object. In the scaling process, we either compress or expand the dimension of
the object.
Scaling operation can be achieved by multiplying each vertex coordinate (x, y) of the polygon by scaling factor sx and sy to produce the transformed coordinates as (x’, y’).
So,
Scaling operation can be achieved by multiplying each vertex coordinate (x, y) of the polygon by scaling factor sx and sy to produce the transformed coordinates as (x’, y’).
So,
x’ = x * sx and y’ = y * sy.
The scaling factor sx, sy scales the object in X and Y direction respectively. So, the above equation can be represented in matrix form:
Note: If the scaling factor S is less than 1, then we reduce the size of the object. If the scaling factor S is greater than 1, then we increase size of the object.
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’).
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.
We
can write it as −
P’ = P + T
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’).
x′ = xcosθ − ysinθ
Comments
Post a Comment