Chapter-5 2D Transformations Basic Transformations: T T y X y X
Chapter-5 2D Transformations Basic Transformations: T T y X y X
2D Transformations
Basic Transformations
1. Translation
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
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.
1
Matrix Representation
P’ = R . P, which is expanded as
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
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.
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
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
4
Transformations between coordinate systems
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
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.
• Translations