Вы находитесь на странице: 1из 8

Computer Graphics

Chapter-3
Geometric Transformation

Transformation: A transformation is a process of change the size of an object or


shape of an object, orientation and position of an object. The above transformation is
called as ‘Geometric transformation’.
Or
Geometric transformations are changes produced in orientation, size and shape
which alter the co-ordinates of the objects.
They are two types of transformation, they are:

 Basic transformation  Other or miscellaneous transformation


 Translation  Reflection
 Scaling  Shear
 Rotation

Basic Transformation:

1. Translation: Is the ability to reposition an image or object along a straight line


path from one location to another in the co-ordinate system.
We translate a point from one co-ordinate position(x,y) to new co-ordinate
position (x1, y1 ) by adding translation distance tx along x-direction and ty along y-
direction to the original co-ordinate. The translation distance pair (Tx,Ty) is called as
‘Translation vector’ or ‘Shift vector’ or ‘Translation parameter’.
The general form of the translation transformation can be expressed as
X_new=x+Tx and y_new=y+Ty
Above transformation equations can be expressed in singular matrix or single
column matrix or vector representation as
The object drawn with curved objects such as circle, ellipse are translated by
changing the center co-ordinates and redraw the curved objects with new location.
The translation equation is
If p=[ x,y,1]
T=[Tx,Ty]
Then p_new=[x_new,y_new,1]

KFGSC, Tiptur
Computer Graphics

The two dimension translation equation in the form


P_new=P+T
X_new=x+Tx
Y_new=Y+TY
The matrix format of the above equation is

[ x_new,y_new,1]=[x,y,1] 1 0 0

0 1 0

Tx Ty 1

If the translation distance identifies the image beyond the display limits, then
the system might either return an appropriate error message or may even clip part of
the image which fall beyond the limits or may present a distorted image which
contains no precession. One of the effect of ‘wrap around’ where a stored image is
displayed on either side of the screen as shown bellow.

 WAP program to draw a triangle and perform translation transformation.

2. Scaling: A transformation to alter the size of an object is called ‘scaling


transformation’. This operation can be carried out for polygons by multiplying the co-
ordinate values(x, y) for each boundary vertex by scaling vector ‘sx’ and ‘sy’ to
produce transformed co-ordinate(x1, y1).

KFGSC, Tiptur
Computer Graphics

The scaling factor sx scales the object in x-direction and scaling factor sy scales
the object in y-direction. The sx and sy are +ve nonzero values.
 If the values are > one, produce an enlargement and object move away from
the co-ordinate origin.
 If the values are < one, produce the diminishing an object and move towards
the co-ordinate origin.
 If the values are = one, no change takes place
 If sx and sy are the same value, a uniform scaling is produced.
 If sx and sy are unequal values, change the shape of an object after scaling.

The scaling from the point (x, y) to a new point


( x_new, y_new) be performed as
(x_new,y_new,1)=[x,y,1]
Sx 0 0

0 Sy 0

0 0 1

X_new =XF+(x- XF).Sx


y_new =yF+(y- yF).Sy

 W.A.P. to draw a triangle and perform scaling transformation.

KFGSC, Tiptur
Computer Graphics

Rotation: Transformation of an object points along circular path is called ‘Rotation’.


We specify rotation transformation with a rotation angle, which determine the amount
of rotation for each vertex of a polygon.

In this figure, the angle Φ is the original angular position of the object point from the
horizontal [00], we can determine the transformation equation for rotation of the
object points from the relationship between the sides of the right angle triangle and
associated with the angle of displacement using these triangle and standard
trigonometric identities,

Xh=x.w & Y,h= Y.w


To find the angular displacement θ from the horizontal [00] to find the corresponding
(x” ,y”) points as,
P=[X,Y,1] and
R=[θ]
R_new=[x_new,y_new,1]
Rearranging the above equation as,
P_new=P.R[θ]
Here ‘r’ is the distance of the point from the co-ordinate origin.
x_new=x.cosθ- y sinθ
y_new= y.cosθ+xsinθ
In general, the matrix format is

cosθ sinθ 0
[x_new,y_new,1]=[x,y,,1]
-sinθ cosθ 0

0 0 1

+ve value for θ in the above equation indicates the counter clockwise rotation –ve
values for θ rotation for an object in clockwise direction.
 Write a program to draw a triangle and perform rotation transformation.
Matrix representation and homogeneous co-ordinate system : Homogeneous
co-ordinates refers to the representation of points on Cartesian equation, When a
Cartesian point(x, y) is converted to a homogeneous representation (xh , yh , h),

KFGSC, Tiptur
Computer Graphics

where parameter h is assigned a non-zero value in accordance with a class of


transformation to be represented.
The basic transformation equation can be represented as matrix multiplication
employing 3 x 3 transformation matrix.
1. Translation :

[ x_new,y_new,1]=[x,y,1] 1 0 0

0 1 0

Tx Ty 1

2. Scaling :
[ x_new,y_new,1]=[x,y,1] Sx 0 0

0 Sy 0

0 0 1

3. Rotation :
[ x_new,y_new,1]=[x,y,1] cosθ sinθ 0

-sinθ cosθ 0

0 0 1

Composite transformation: When a transformation is applied more than once, such


a transformation is called composite transformation. Any sequence of transformation
can be represented as composite transformation. This can be obtained by calculating
the product of individual transformation matrices. The transformation of such
matrices is called as concatenation or composition of matrices.

1. Translation: In order to apply two successive translation of an object, we can


first perform the concatenation of the translation matrix and then apply composite
matrix to the co-ordinate points. The translation distance or vector to the first
transformation matrix is,

KFGSC, Tiptur
Computer Graphics

1 0 0 1 0 0 1 0 0

0 1 0 0 1 0 = 0 1 0

Tx1 Ty1 1 Tx2 Ty2 1 Tx1+ Tx2 Ty1 +Ty2 1

The general form of composite transformation can be written as


T[Tx1,Ty1] T[Tx2,Ty2] = T [Tx1+ Tx2,Ty1 +Ty2]

2. Scaling : Concatenating transformation matrices for two successive scaling


operation produce composite scaling transformation,

Sx1 0 0 Sx2 0 0 Sx1. Sx2 0 0

0 Sy1 0 0 Sy2 0 0 Sy1 .Sy2 0

0 0 1 0 0 1 0 0 1

The general form of composite transformation can be written as


S[Sx1,Sy1] S[Sx2,Sy2] = S [Sx1. Sx2, Sy1. Sy2]

3. Rotation : Concatenation transformation matrices for two successive rotation


operation produce composite rotation transformation,

Cosθ1 sinθ1 0 Cosθ2 sinθ2 0 Cos(θ1+θ2) sin(θ1+θ2) 0

-sinθ1 cosθ1 0 -sin(θ1+θ2) cos(θ1+θ2) 0


-sinθ2 cosθ2 0 =
0 0 1 0 0 1
0 0 1

The general form of composite transformation can be written as


R[θ1] R[θ2]=R[θ1+θ2]
Other Transformation: Certain packages provided additional transformations which
are useful in certain applications. They are, Reflection and shear.

KFGSC, Tiptur
Computer Graphics

1. Reflection: Reflection is a transformation that produces a mirror image of an


object. The mirror image is generated w.r.t relative axis of reflection. Object can be
reflected about the specified axis such as x-axis, y-axis, xy-axis and y=x axis.

a. Reflection about x-axis :


An object can be reflected about x-axis using the following transformation matrix,

1 0 0

0 -1 0

0 0 1

In this transformation keep the x-value as it is, flip or change the value of y.

b. Reflection about y-axis :

The object can be reflected about y-axis using the following transformation matrix,

-1 0 0

0 1 0

0 0 1

In this transformation keep the y-axis and it is flip or change the value of x.

c. Reflection about xy-axis :


In this transformation flip x & y co-ordinates by reflecting relative to the co-ordinate
origin. The transformation equation as

-1 0 0

0 -1 0
KFGSC, Tiptur
0 0 1
Computer Graphics

2. Shear Transformation :
Shear is the ability to distort the shape of an object such that the
transformed object appears as if it has been created by sliding the internal layer if
the original object.

1 0 0

SHx 1 0

0 0 1

KFGSC, Tiptur

Вам также может понравиться