COMPUTER GRAPHICS
BIT 2301 A/ BAC 3206
2D TRANSFORMATION
CONTENT
1. Transformation
2. Scaling
3. Rotation
4. Reflection
5. Shearing
6. Matrix representation
7. Homogeneous Coordinates
8. Composite transformation
TRANSFORMATION
• Computer Graphics provide the facility of viewing object from
different angles. The architect can study building from different
angles i.e.
1. Front Evaluation
2. Side elevation
3. Top plan
• A Cartographer can change the size of charts and topographical
maps. So if graphics images are coded as numbers, the numbers
can be stored in memory. These numbers are modified by
mathematical operations called as Transformation.
• The purpose of using computers for drawing is to provide facility
to user to view the object from different angles, enlarging or
reducing the scale or shape of object called as Transformation.
ASPECTS OF TRANSFORMATION
• Two essential aspects of transformation are given
below:
1. Each transformation is a single entity. It can be
denoted by a unique name or symbol.
2. It is possible to combine two transformations,
after connecting a single transformation is
obtained, e.g., A is a transformation for
translation. The B transformation performs
scaling. The combination of two is C=AB. So C is
obtained by concatenation property.
POINTS OF VIEW IN TRASNFORMATION
• There are two complementary points of view for
describing object transformation.
1. Geometric Transformation: The object itself is
transformed relative to the coordinate system or
background. The mathematical statement of this
viewpoint is defined by geometric transformations
applied to each point of the object.
2. Coordinate Transformation: The object is held
stationary while the coordinate system is transformed
relative to the object. This effect is attained through
the application of coordinate transformations.
POINTS OF VIEW IN
TRASNFORMATION……….
• An example that helps to distinguish these two
viewpoints:
• The movement of an automobile against a scenic
background we can simulate this by
1. Moving the automobile while keeping the
background fixed-(Geometric Transformation)
2. We can keep the car fixed while moving the
background scenery- (Coordinate
Transformation)
TYPES OF TRANSFORMATIONS
1. Translation
2. Scaling
3. Rotating
4. Reflection
5. Shearing
TRANSLATION
• It is the straight line movement of an object from
one position to another is called Translation. Here
the object is positioned from one coordinate
location to another.
• Translation of point: To translate a point from
coordinate position (x, y) to another (x1 y1), we add
algebraically the translation distances Tx and Ty to
original coordinate.
• x1=x+Tx
• y1=y+Ty
TRANSLATION…..
• The translation pair (Tx,Ty) is called as shift vector.
• Translation is a movement of objects without
deformation. Every position or point is translated by the
same amount. When the straight line is translated, then
it will be drawn using endpoints.
• For translating polygon, each vertex of the polygon is
converted to a new position. Similarly, curved objects
are translated. To change the position of the circle or
ellipse its center coordinates are transformed, then the
object is drawn using new coordinates.
• Let P is a point with coordinates (x, y). It will be
translated as (x1 y1).
• P1(2,3) to P2
P2
X2= X1+Tx
Y2= Y1+Ty
X2=2+()
Y2=3+()
X2= 2+(1)
Y2=3+(1)
P2(3,4)
SCALING
• It is used to alter or change the size of objects. The change is done using
scaling factors. There are two scaling factors, i.e. S x in x direction Sy in y-
direction. If the original position is x and y. Scaling factors are S x and
Sy then the value of coordinates after scaling will be x 1 and y1.
• If the picture to be enlarged to twice its original size then S x = Sy =2. If
Sxand Sy are not equal then scaling will occur but it will elongate or
distort the picture.
• If scaling factors are less than one, then the size of the object will be
reduced. If scaling factors are higher than one, then the size of the
object will be enlarged.
• If Sxand Syare equal it is also called as Uniform Scaling. If not equal then
called as Differential Scaling. If scaling factors with values less than one
will move the object closer to coordinate origin, while a value higher
than one will move coordinate position farther from origin.
SCALING….
• Enlargement: If T1= ,If (x1 y1)is original position
and T1is translation vector then (x2 y2) are
coordinated after scaling
SCALING…..
• Reduction: If T1= . If (x1 y1) is original position
and T1 is translation vector, then (x2 y2) are
coordinates after scaling.
Example
• Prove that 2D Scaling transformations are
commutative i.e, S1 S2=S2 S1.
• Solution: S1 and S2 are scaling matrices
ROTATION
• It is a process of changing the angle of the object.
Rotation can be clockwise or anticlockwise. For
rotation, we have to specify the angle of rotation
and rotation point. Rotation point is also called a
pivot point. It is point about which object is
rotated.
Types of Rotation
1. Anticlockwise
2. Counterclockwise
• The positive value of the pivot point (rotation angle) rotates an object in a
counter-clockwise (anti-clockwise) direction.
• The negative value of the pivot point (rotation angle) rotates an object in a
clockwise direction.
• When the object is rotated, then every point of the object is rotated by the same
angle.
• Straight Line: Straight Line is rotated by the endpoints with the same angle and
redrawing the line between new endpoints.
• Polygon: Polygon is rotated by shifting every vertex using the same rotational
angle.
• Curved Lines: Curved Lines are rotated by repositioning of all points and drawing
of the curve at new positions.
• Circle: It can be obtained by center position by the specified angle.
• Ellipse: Its rotation can be obtained by rotating major and minor axis of an ellipse
by the desired angle.
EXAMPLES
ROTATION MATRICES
• Matrix for rotation is a clockwise direction.
• Matrix for rotation is an anticlockwise direction.
• Matrix for homogeneous co-ordinate rotation
(clockwise)
• Matrix for homogeneous co-ordinate rotation
(anticlockwise)
• (2,5) (0.866,0.5/0.5, 0.866)
• 2*0.866+5*0.5 2*0.5+5*0.866
• 1.732+2.5 1+4.33
• (2,5) to (4.232,5.33)
Rotation about an arbitrary point
If we want to rotate an object or point about an
arbitrary point, first of all, we translate the point
about which we want to rotate to the origin. Then
rotate point or object about the origin, and at the
end, we again translate it to the original place. We
get rotation about an arbitrary point.
• Example: The point (x, y) is to be rotated
• The (xc yc) is a point about which counterclockwise
rotation is done
arbitrary point….
• Step1: Translate point (xc yc) to origin
arbitrary point…..
• Step2: Rotation of (x, y) about the origin
arbitrary point…..
• Step3: Translation of center of rotation back to
its original position
Example1:
• Prove that 2D rotations about the origin are
commutative i.e. R1 R2=R2 R1.
• Solution: R1 and R2are rotation matrices
Example2
• Rotate a line CD whose endpoints are (3, 4) and
(12, 15) about origin through a 45° anticlockwise
direction. Solution: The point C (3, 4)
ASSIGNMENT
• Rotate line AB whose endpoints are A (2, 5)
and B (6, 12) about origin through a 30°
clockwise direction.
REFLECTION
• It is a transformation which produces a mirror
image of an object. The mirror image can be either
about x-axis or y-axis. The object is rotated by180°.
• Types of Reflection:
1. Reflection about the x-axis
2. Reflection about the y-axis
3. Reflection about an axis perpendicular to xy
plane and passing through the origin
4. Reflection about line y=x
Reflection about x-axis
• The object can be reflected about x-axis with the
help of the following matrix
In this transformation value of x will remain same
whereas the value of y will become negative.
Following figures shows the reflection of the object
axis. The object will lie another side of the x-axis.
Reflection about y-axis
• The object can be reflected about y-axis with the
help of following transformation matrix
• Here the values of x will be reversed, whereas the
value of y will remain the same. The object will lie
another side of the y-axis.
Reflection about an axis perpendicular to xy plane and passing
through origin
In this value of x and y both will be reversed. This is also called as half revolution about the origin .
Reflection about line y=x
• The object may be reflected about line y = x
with the help of following transformation
matrix
Example
• A triangle ABC is given. The coordinates of A,
B, C are given as
• A (3 4)
B (6 4)
C (4 8)
• Find reflected position of triangle i.e., to the x-
axis.
solution
Solution….
• The a point coordinates after reflection
• The b point coordinates after reflection
• The c point coordinates after reflection
• a (3, 4) becomes a1 (3, -4)
b (6, 4) becomes b1 (6, -4)
c (4, 8) becomes c1 (4, -8)
SHEARING
• It is transformation which changes the shape of
object. The sliding of layers of object occur. The
shear can be in one direction or in two directions.
• Shearing in the X-direction: In this horizontal
shearing sliding of layers occur. The homogeneous
matrix for shearing in the x-direction is shown
below:
SHEARING….
• Shearing in the Y-direction: Here shearing is
done by sliding along vertical or y-axis.
• Shearing in X-Y directions: Here layers will be
slided in both x as well as y direction. The
sliding will be in horizontal as well as vertical
direction. The shape of the object will be
distorted. The matrix of shear in both
directions is given by:
Assignments
Go read on:
1. Matrix representation
2. Homogeneous Coordinates
3. Composite transformation
• Thanks