1. Amity Institute of Information Technology
AIIT
COMPUTER GRAPHICS
Two Dimensional Geometric
Transformation
AMITY UNIVERSITY, NOIDA
INDIA
2. Amity Institute of Information Technology
AIIT
Contents
– Why transformations
– Transformations
• Translation
• Scaling
• Rotation
• Reflection
• Shearing
– Homogeneous coordinates
– Combining transformations
3. Amity Institute of Information Technology
AIIT
Transformations
• In graphics, once we have an object described,
transformations are used to move that object, scale it
and rotate it The process of change in size,orientation
or positions of objects by a mathematical operation is
called Transformation.
4. Amity Institute of Information Technology
AIIT
Types of Transformation
1) Geometric Transformations: In this type of
transformations, the object itself is moved relative to
a stationary coordinate system or background.
2) Coordinate Transformations: In this type of
transformation, the object is held stationary while the
coordinate system is moved relative to the object.
5. Amity Institute of Information Technology
AIIT
Cartesian Coordinate System
• A number line can be used to represent a number or solution of an
equation that only has one variable. It is sufficient to describe the
solution of one-valued equations because they all are single-
dimensional.
• But as the number of variables in an equation increases, it is not
enough. For example when the number of variables in an
equation becomes two, there will be pair of numbers as a solution.
This is why the concept of the number line has to be extended.
There should be 2 number lines now, but how will we show our
solution on it?
• So, instead of a line, let’s define a plane to plot the solutions now.
6. Amity Institute of Information Technology
AIIT
Cartesian Plane and Coordinates
• Cartesian Plane:
• A Cartesian plane is defined by two perpendicular number lines, X
and Y. It extends to infinity in both directions. It has a centre
usually denoted by O.
• The horizontal line is called X-axis while the vertical line is
called Y-axis.
• Cartesian Coordinates:
• Cartesian Coordinates are used to mark the plane about a point.
How far up/down or how far left/right it is.
• They are always written in a certain order:
• Horizontal distance
• Vertical Distance
• This is called an “ordered pair” (a pair of numbers in a special
order) and usually, the numbers are separated by a comma, and
parentheses are put around the whole thing like (5,4).
7. Amity Institute of Information Technology
AIIT
Types of Transformation
1. Translation
2. Scaling
3. Rotation
4. Reflection
5. Shearing
8. Amity Institute of Information Technology
AIIT
Translation
• Simply moves an object from one position to another
• xnew = xold + tx ynew = yold + ty
• The pair (tx , ty) is called translation vector or shift vector
Note: House shifts position relative to origin
y
x
0
1
1
2
2
3 4 5 6 7 8 9 10
3
4
5
6
9. Amity Institute of Information Technology
AIIT
Translation Example
y
x
0 1
1
2
2
3 4 5 6 7 8 9 10
3
4
5
6
(1, 1) (3, 1)
(2, 3)
(6, 4)
tx
(7, 2)
(5, 2)
=4
=1
ty
10. Amity Institute of Information Technology
AIIT
• In matrix representation we can write translation as
11. Amity Institute of Information Technology
AIIT
Rotation
Rotates all coordinates by a specified angle
• xnew = xold × cosθ – yold × sinθ
• ynew = xold × sinθ + yold × cosθ
• Points are always rotated about the origin
• The convention is that the direction of rotation is
counterclockwise if θ is positive angle and clockwise if θ is
negative angle y
x
0
1
1
2
2
3 4 5 6 7 8 9 10
3
4
5
6
12. Amity Institute of Information Technology
AIIT
• Rotation can be represented as:
13. Amity Institute of Information Technology
AIIT
Scaling
• Scalar multiplies all coordinates
• WATCH OUT: Objects grow and move!
• xnew = Sx × xold ynew = Sy × yold
• The pair (Sx , Sy) is called Scaling vector
Note: House shifts position relative to origin
y
x
0
1
1
2
2
3 4 5 6 7 8 9 10
3
4
5
6
14. Amity Institute of Information Technology
AIIT
Scaling Example
y
0 1
1
2
2
3 4 5 6 7 8 9 10
3
4
5
6
(1, 1) (3, 1)
(2, 3)
Scaling vectors=(2,2)
15. Amity Institute of Information Technology
AIIT
Scaling transformation can be represented as
17. Amity Institute of Information Technology
AIIT
Reflection
• 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.
Y
X
O
Original
object
Reflected
object
18. Amity Institute of Information Technology
AIIT
Reflection Transformation matrix
Reflection about
Y-axis
-1 0 0
0 1 0
0 0 1
Reflection about
X-axis
1 0 0
0 -1 0
0 0 1
Reflection about
origin
-1 0 0
0 -1 0
0 0 1
Reflection about diagonal axis (line
y=x)
0 1 0
1 0 0
0 0 1
Reflection about
Line y = - x
0 -1 0
- 1 0 0
0 0 1
19. Amity Institute of Information Technology
AIIT
Shearing
• A transformation that slants the shape of an object is called the
shear transformation.
• Two common shearing transformations are
– X-shear
– Y-shear
X-Shear
• The X shear preserves the y coordinates, but changes the x
values which causes vertical lines to tilt right or left.
20. Amity Institute of Information Technology
AIIT
Y Shear
• The Y shear preserves the x coordinates, but changes
the y values which causes horizontal lines to tilt up or
down.
21. Amity Institute of Information Technology
AIIT
Inverse Geometric Transformation
• Each geometric transformation has an inverse which is
described by the opposite operation performed by the
transformation.
23. Amity Institute of Information Technology
AIIT
Homogeneous Coordinates
• To express any two-dimensional transformation as a matrix
multiplication, we represent each Cartesian coordinate position
(x,y) with the homogeneous coordinate triple(xh,yh,h) where
x = xh/ h y= yh /h
• But it is convenient to have h = 1. Therefore, each two-
dimensional position can be represented with homogenous
coordinate as (x, y, 1).
• Other values for parameter h are needed in matrix formulations
of 3-D viewing transformations.
• Expressing positions in homogeneous coordinates allows us to
represent all geometric transformation equations as matrix
multiplication.
• Coordinates are represented with three-element column
vectors,and tranformation operations are written as 3 by 3
matrices.
24. Amity Institute of Information Technology
AIIT
Composite Transformation
• A Composite Transformation is a transformation that consists
of more than one step to the transformation.
• For example, translate an object and then, do a second
translation on the product, to again move the object.
• There can be a combination of two different transformations.
For example, translate the object and then perform a size
transformation.
25. Amity Institute of Information Technology
AIIT
Numerical 1
• Find the matrix that represents rotation of an object by
30 degree about the origin
• What are the new coordinates of the point P(2,-4) after
the rotation.
26. Amity Institute of Information Technology
AIIT
Numerical 2
• Q) Translate a point P (2,5) by 3 units in x direction
and 4 units in Y direction.
27. Amity Institute of Information Technology
AIIT
Numerical 3
• Translate a polygon with coordinates A(2,5) B(7,10)
and C(10, 2) by 3 units in X direction and 4 units in Y
direction.
28. Amity Institute of Information Technology
AIIT
Numerical 4
• Find the transformation that scales (w.r.t origin) by
(i) a units in x direction
(ii) b units in y direction
(iii) a units in the x direction and b units in the y direction
29. Amity Institute of Information Technology
AIIT
Numerical 5
• Q) Scale the polygon with coordinates A(2,5) B(7,10)
and C(10,2) by two units in X direction and two units in
Y direction.
30. Amity Institute of Information Technology
AIIT
General Pivot Point Rotation
1) Translate the object so that the pivot-point position is
moved to the coordinate origin.
2). Rotate the object about the coordinate origin.
3).Translate the object so that the pivot point is returned
to its original position.
31. Amity Institute of Information Technology
AIIT
General Fixed Point Scaling
• Translate object so that the fixed point coincides with
the coordinate origin.
• Scale the object with respect to the coordinate origin.
• Use the inverse translation of step 1 to return the
object to its original position.
32. Amity Institute of Information Technology
AIIT
Numerical 6
• Perform a 45 degree rotation A(0,0), B(1,1) , C(5,2)
a) About the origin b) About P(-1,-1).
33. Amity Institute of Information Technology
AIIT
Numerical 7
• Q) Prove that two successive 2D rotations are additive.
34. Amity Institute of Information Technology
AIIT
Numerical 8
• Magnify a triangle with vertices A (0,0), B(1,1) and
C(5,2) to twice its size while keeping C(5,2) fixed.
35. Amity Institute of Information Technology
AIIT
Numerical 9
• Find a transformation of triangle A(1,0), B(0,1), C(1,1)
by rotating 45 degree about the origin and then
translating one unit in x and y direction.
36. Amity Institute of Information Technology
AIIT
Numerical 10
Q) Apply the shearing transformation to square with
A(0,0), B(1,0), C(1,1) and D(0,1) as given below:
(a) Shear Parameter value of 0.5 relative to the line
Yref=-1
(b) Shear Parameter value of 0.5 relative to the line
Xref=-1
37. Amity Institute of Information Technology
AIIT
Numerical 12
• Describe the transformation that rotates an object point
Q(x,y) θ degree about a fixed center of rotation p(h,k),
and find the matrix for rotation about a point p(h,k)
38. Amity Institute of Information Technology
AIIT
Numerical 13
• Reflect the diamond shaped polygon whose vertices
are A(-1,0), B(0,-2), C(1,0) and D(0,2) about
(a) The horizontal line y=2
(b) The vertical line x=2
(c) The line y=x+2