Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
2d-transformation
1. Prof. Neeraj Bhargava
Pooja Dixit
Department of Computer Science
School of Engineering & System Sciences
MDS, University Ajmer, Rajasthan, India
1
2. In 2D object, transformation is to change the
object’s
◦ Position (translation)
◦ Size (scaling)
◦ Orientation (rotation)
◦ Shapes (shear)
◦ Reflection(Mirror image)
Transformations play an important role in
computer graphics to reposition the graphics
on the screen and change their size or
orientation.
2
3. 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’).
3
4. From the above figure,−
X’ = X + tx
Y’ = Y + ty
Here (tx, ty) is called the translation vector or shift vector.
The above equations can also be represented using the column
vectors.
P =[X ] p' = [X ′] T = [tx]
[Y ] [Y ′] [ty]
We can write it as −
P’ = P + T
4
5. Rotation is a little more complex than translation because you
have to specify multiple items of information. The following
three items are required:
Rotation axis (the axis the shape will be rotated around)
Rotation direction (the direction: clockwise or counterclockwise)
Rotation angle (the number of degrees the shape will be rotated
through)
5
6. Thus the rotation of a 2D
vector in a plane is done as
follows:
6
7. The final coordinate system transformation is scaling, which
changes the size of the grid. Take a look at this example,
which draws a triangle, then scales the grid to twice its
normal size, and draws it again.
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
7
8. The scaling factor SX, SY scales the object in X and
Y direction respectively. The above equations can
also be represented in matrix form as below −
Or P’ = S . P
Scaling process:
8
9. Reflection in computer graphics is used to emulate reflective
objects like mirrors and shiny surfaces.
A reflection is a transformation that produces a mirror image of
an object relative to an axis of reflection. We can choose an axis
of reflection in the xy plane or perpendicular to the xy plane.
9
12. A transformation that slants the shape of an object is called
the shear transformation.Two common shearing transfor-
mations are used.One shifts x co-ordinate values and other
shifts y co-ordinate values. However, in both the cases only
one co-ordinate (x or y) changes its co-ordinates and other
preserves its values.
X Shear:-
The x shear preserves the y co-ordinates, but changes the x
values which causes vertical lines to tilt right or left as shown
in the figure below . The transformation matrix for x shear is
given as:
12
14. Y shear:-
The y shear preserves the x coordinates, but changes the y
values which causes horizontal lines to transform into lines
which slope up or down, as shown in the figure below. The
transformation matrix for y shear is given as
14