Computer Graphics
K. Adisesha
1
2D Transformations
A transformation is any operation on a point in space (x, y) that maps the point's coordinates into a new set
of coordinates (x1,y1).
Translation
In translation an object is displaced a given distance and direction from its original position. If the
displacement is given by the vector v = txI + tyJ, the new object point P
'
(x
'
, y
'
) can be found by applying
the transformation Tv to P(x, y). See the figure below
P
'
= Tv(P)
where x
'
= x + tx and y
'
= y + ty.
As an example, consider a triangle defined by three vertices (20,0), (60, 0), and (40, 100) being translated
100 units to the right along the x-axis ( tx = 100) and 10 units up along the y-axis (ty = 10). The new
vertices are (120, 10), (160, 10), and (140, 110), see figure below:
Rotation
In rotation, the object is rotated ø° about the origin. The convention is that the direction of the rotation is
CCW if ø is a positive angle and CW if the ø is a negative angle. The transformation for rotation Rø is
P
'
= Rø(P)
where x
'
= x cos(ø) - y sin(ø) and y
'
= x sin(ø) + y cos(ø)
For example a triangle (20,0), (60,0), (40,100) rotated 45° clockwise about the origin is (14.14, -14.14),
(42.43, -42.43), (98.99, -42.43)