Chapter-5
2D Transformations
Basic Transformations
1. Translation
A Translation operation involves repositioning an object along a straight-line path (the
translation distances) from one coordinate location to another. We translate a 2D point by adding
translation distances tx and ty to point (x,y).
x’=x+ tx
y’=y+ ty
The translation distance pair (tx, ty) is called translation vector or shift vector.
Matrix Representation
x ' x t x
y ' = y + t
y
P' = P + T
Where P = ( x, y ), T = (t x , t y )
Example
Let P = ( −3,−4), T = (7,8)
So,
x ' = −3 + 7
y ' = −4 + 8
x ' − 3 7
y ' = − 4 + 8
2. Rotation
A 2D rotation is applied to an object by repositioning it along a circular path in the xy plane. For
rotation, we need a rotation point (pivot) and a rotation angle. If rotation angle is positive, rotation
is done in clock-wise direction. If rotation angle is negative, rotation is done in anti clock-wise
direction.
The transformation equation is given by,
1
Matrix Representation
P’ = R . P, which is expanded as
x ' cos (θ ) − sin (θ ) x
y ' = sin (θ ) cos (θ ) y
3. Scaling
A scaling transformation alters the size of an object. It is achieved by multiplying the co co-ordinates
(x,y) by a scaling factor (sx,sy). Sx scales in x-direction and Sy scales in y-direction.
direction. When Sx=Sy, then it
produces Uniform scaling else differential scaling.
scaling. When the scaling factor values are less than 1, it
moves towards the origin, else away from origin.
Equation
x’=x.sx
y’=y.sy
Matrix Representation
x ' sx 0 x
y ' = 0 sy y or
P’ = S . P
2. Other Transformations
1. Reflection
A reflection is a transformation that produces a mirror image of an object. It is generated by
rotating 180o about the reflection axis. We can choose an axis of reflection
lection in the xy plane or
perpendicular to the xy plane. If reflection axis is in the xy plane, the rotation path is in plane
perpendicular to xy and vice versa.
Matix Representation
2
1 0 0 −1 0 0 −1 0 0
0 −1 0 0 1 0 0 −1 0
0 0 1 0 0 1 0 0 1
Reflection about the x-axis (keeps x Reflection about the y-axis (keeps y Reflection about the origin
value same, but flip y values value same, but flip x values
2. Shear
A transformation that distorts the shape of an object such that the transformed shape appears as if the
object were composed of internal layers that had been caused to slide over each other is called a shear. Two
common shearing transformations are those that shift x values and those that shift y values.
Basic Equation and Matrix
x ' = x + shx * y x ' 1 sh x x
y ' = shy * x + y y ' = sh 1 y
y
Matrix Representations and Equation
1 ݏℎݔ 0 1 ݏℎݔ −ݏℎݔ. ݂݁ݎݕ 1 0 0
0 1 0 0 1 0 ݏℎݕ 1 −ݏℎ. ݂݁ݎݔ
0 0 1 0 0 1 0 0 1
x’=x + shx . y x’=x + shx (y-yref) x’=x
y’ = y y’=y y’=shy(x-xref) + y
x-direction shear x-direction shear relative to other y-direction shear relative to line x=xref
reference lines
3. Composite Transformations
It is possible to combine transformation operation by matrix multiplication. For eg, to combine
translation, rotation and scaling, the matrix multiplication of their respective matrices can be done.
It is possible to obtain a single transformation matrix by multiplying the respective matrices.
General Format
x ' a b e f i j x
y ' = c d g h k l y
Example
x ' 1 0 tx cos Θ − sin Θ 0 sx 0 0 x
y ' = 0 ty sin Θ cos Θ 0 0
0 y
1 sy
1 w
w ' 0 0 1 0 0 1 0 0 3
Translation
If we want to apply two translations T1 and T2 on P(x,y).
P’= (T2 . T1) . P
P’= {T2(tx2,ty2) . T1(tx1,ty1)} . P
The matrix is as given below :
1 0 tx 2 1 0 tx1 1 0 tx1 + tx 2
0 1 ty 2 0 1 ty1 = 0 1 ty1 + ty 2
0 0 1 0 0 1 0 0 1
Rotation
P’=R(θ2) . [R(θ1) . P]
= [R(θ2) . [R(θ1)] . P
= R(θ1+θ2) . P
Scaling
sx 2 0 0 sx1 0 0 sx1.sx 2 0 0
0 sy 2 0 0 sy1 0 = 0 sy1.sy 2 0
0 0 1 0 0 1 0 0 1
i.e. S(sx2,sy2) . S(sx1,sy1) = S (sx1 . sx2, sy1 . sy2)
General Pivot-Point Rotation- Operation
Translate (pivot point is moved to origin)
Rotate about origin
Translate (pivot point is returned to original position)
T(pivot) • R(θ) • T(–pivot)
4
Transformations between coordinate systems
1. Translate so that the origin (x,,y0) of the x’y’
x system is moved
oved to the origin of the xy system
2. Rotate the x’ axis onto the x axis.
General Fixed-Point Scaling – Operation
a. Translate (fixed point is moved to origin)
b. Scale with respect to origin
c. Translate (fixed point is returned to original position)
T(fixed) • S(scale) • T(–fixed)
fixed)
General Scaling Directions- Operation
ion
a. Translate so that (x,y) becomes origin
b. Scale with respect to origin
c. Rotate (scaling direction is returned to original position)
5
Note :
1. Parameters sx and sy scale objects along the x and y directions. We can scale an object
in other directions by rotating the object to align the desired scaling directions with the
coordinate axes before applying the scaling transformations.
2. Matrix multiplication is associative
associativ
i.e. A.B.C=(A.B).C=A.(B.C)
4. Affine Transformations
Affine Transformations have the property of preserving parallelism of lines and finite points
remain finite. ( but not of lengths and angles)
angles Examples of affine transformations are rotation,
translation, and scaling.
Affine transformations are combinations of …
• Linear transformations, and
• Translations
Properties of affine transformations:
formations:
• Origin does not necessarily map to origin
• Lines map to lines
• Parallel lines remain parallel
• Ratios are preserved
• Closed under composition