CHAPTER - THREE
TRANSFORMATION
1
Two-Dimensional Transformation
Transformation means a change in either position ,size, shape or
orientation of any graphical object
When a transformation takes place on a 2D plane it called 2D
transformation.
Different types of transformation are:
1. Translation
2. Scaling
3. Rotation
4. Reflection
2
5. Shearing
1. Translation
A translation is applied to an object by repositioning it along a
straight line path from one coordinate location to another.
We translate a two-dimensional point by adding translation
distance and to the original coordinate position (x,y) to
move the point to a new position (x’, y’).
x’ = x + and y’ = y +
The translation distance pair ( , ) is called a translation 3
Cont’d …
In matrix form it is represented as the following transformation equation:
P’ = P + T
Where P = , P’ = and T = => translation matrix
Translation is a rigid – body translation that moves objects without deformation
.
A straight line segment is translated by applying the transformation equation
to each of the line end points and redrawing the line between new end points.
Polygons are translated by adding the translation vector to the coordinate
position of each vertex and regenerating the polygon using new set of vertex
coordinates
To translate a circle or ellipse we translate the center coordinates and redraw
the circle or ellipse in the new center 4
Cont’d …
Example: Translate the line between end points A (2,-1) and B
(3,4) with translation factors = 2 , = 3
Solution : A = => + => + =
B = => + => + =
B’(5,
7)
B(3,
4)
A’(4,
2)
A(2,-
1)
5
2. Scaling
A scaling transformation changes the size of an object
In the scaling process either we can expand or compress the
dimension of the object
Scaling can be achieved by multiplying the original coordinates of
the object with the scaling factor to get the desired result
Let (x,y) be the original coordinates , the scaling factors are :
: scaling factor along x- axis
: scaling factor along y- axis
And the produced coordinates are (x’, y’) , mathematically as follows
x’ = x ∙ and y’ = y ∙ 6
Cont’d …
If denote (x,y) by P and (x’, y’) by P’ then
P’ = P ∙ S
In matrix form : =
Notes:
1. Any positive numeric value can be assigned to the scaling factor
and
values less than 1 reduce the size of objects whereas values greater
than 1 produces an enlargement.
2. When = the scaling is a uniform scaling
3. When ≠ the scaling is a differential scaling
7
Cont’d …
Example : A rectangle is defined as scale the rectangle with scaling
factor = 2 and = 1
Solution : A’ = = , B’ = =
C’ = = , D’ = =
D(1, C(5, D’(2,3)
C’(10,
3) 3) 3)
A(1, B(5, A’(2, B’(10
1) 1) 1) ,1)
al angl e
origin e d rect
ec t a ngl Scale
r 8
3. Rotation
To generate a rotation ,we have to specify a rotation angle θ and the
position ( , ) of the rotation point about which the object is to be
rotated .
Positive values for the rotation angle define counterclockwise
rotation about the pivot point and negative values rotate objects in
the clockwise direction.
Let us discuss about the rotation of a point P(x,y) when the point is at
the origin (0,0)
Suppose P is a point having coordinate (x,y) is rotated with in an angle 9
Cont’d …
Ø is the original angular position of the point P from the horizontal (x-
axis).
The polar coordinates of P can be expressed as :
x=r
y= r
Similarly, the polar coordinates of P’ can be expressed as :
x’ = r = r ∙ => x -y
y’ = r = + r ∙ => y + x
In matrix : = => Rotation matrix in anti-clockwise
direction
x' xr ( x xr ) cos ( y yr ) sin
Similarly , = => Rotation matrix in clockwise direction
y ' yr ( x xr ) sin ( y yr ) cos
10
Cont’d …
Example : perform a 45-degree rotation of triangle
A(0,0) ,B(1,1) , C(5,2)
a) About the origin
b) About point(-1,-1)
Solution :
a ) = R(45) =
= =
11
Homogeneous Coordinate System
To obtain square matrices an additional row was added to the matrix
and an additional coordinate, the w-coordinate, was added to the
vector for a point.
In this way a point in 2D space is expressed in three-dimensional
homogeneous coordinates.
This technique of representing a point in a space whose dimension is
one greater than that of the point is called homogeneous
representation.
It provides a consistent, uniform way of handling affine
transformations
12
Cont’d …
If we use homogeneous coordinates, the geometric
transformations given above can be represented using only a
matrix pre-multiplication.
A composite transformation can then be represented by a
product of the corresponding matrices.
Cartesian Homogeneous
( x, y )
( xh, yh, h), h 0
a b
, ( a, b, c ), c 0
c c
Examples: (5, 8) (15, 24, 3)
(x, y) (x, y, 1)
13
Cont’d …
Why Do We Use Homogenous Coordinates?
1. We can represent all transformations as matrix multiplication
2. We can capture composite transformations conveniently
3. We can represent a point at infinity which is needed when we want
to represent a point at infinity in a certain direction
For our convenience ,we generally take h=1
(x,y) =>(x,y,1) or =>
Examples: (0,1,2) = (, , ) =>(0, )
(0,0.5,1) => (0,0.5)
14
Homogeneous Coordinate
Representation
1. Translation of :
=
2. Scaling
= or P’ = S(, ).P
3. Rotation
= or P’ = R().P
15
4. Reflection
It is a transformation that produces a mirror image of an
object
The mirror image for a 2D reflection is generated relative to an
axis of reflection by rotating the object 180 degree about the
reflection axis 1
Y
Original position
2 3
2’ 3’
Reflected
position
X
1’ 16
Cont’d …
17
Reflection about the y-axis
Reflection about y-axis is accomplished with transformation matrix is
as follows:
2 2’
3 1 1’ 3’
. This transformation keeps y value same ,but flips x values of the
coordinate positions
X’= - x , y ’= y
18
Reflection about the x-axis
Reflection about x-axis is accomplished with transformation matrix is
as follows:
This transformation keeps x value same ,but flips y values of the
coordinate positions
x’= x , y ’= -y
Reflection about the origin
Reflection of an object relative to an axis perpendicular to the xy
plane and passing through the coordinate origin
transformation matrix is as follows: and both x and y values
flips
x’= -x , y ’= -y
19
Reflection about the line (y=x)
Transformation matrix is as follows
This transformation interchanges both x and y values:
Reflection about the line (y=-x) x’= y , y ’= x
transformation matrix is as follows
This transformation interchanges and flips both x and y values:
x’= -y , y ’= -x
20
21
Example
1. A triangle ABC is given. The coordinates of A, B, C are given
as A (3 4), B (6 4) and C (4 8)
I. Find reflected position of triangle i.e., to the x-axis.
A(3,4) reflected point is (3, -4).
22
5. Shearing
A transformation that slants the shape of an object is called the
shear transformation.
There are two shear transformations X-Shear and Y-Shear.
One shifts X coordinates values and other shifts Y coordinate values.
However; in both the cases only one coordinate changes its
coordinates and other preserves its values.
Shearing is also termed as Skewing.
5.1 X-Shearing
The X-Shear preserves the Y coordinate and changes are made to X
coordinates, which causes the vertical lines to tilt right or left.
Transformation matrix
, where = shearing factor
Transforms coordinate
x’= x+ ∙ y andposition
y ’= as: 23
y
Cont’d …
5.2 Y-Shearing
The Y-Shear preserves the X coordinates and changes the Y coordinates which
causes the horizontal lines to transform into lines which slopes up or down as shown
in the following figure.
Transformation matrix x’= x• and
Transforms
y ’= y coordinate
+ ∙x
position as:
24
, where = shearing factor along y-axis
THANK YOU!
ANY QUESTI
O N S?
25