Sei sulla pagina 1di 4

Basic transformations:

Transformation techniques are applied to perform change in orientation, shape and


sizes on the given objects .
Types of transformations are :
Translation :
Translation is applied to an object by repositioning it along a straight line joining one
coordinate to another .We translate by adding one translation coordinates to previous coordinate
position..
X=X+tx;

(2)

Y=Y+ty;

(1)

Now similar to thus transformation we have to perform many other transformations , this leads
to generation many other equations like eqn 1,2
Thus during programming this may cause lot of problems as code may become lengthy and
complex
Thus we convert these equations in matrix form such as given below..

X= ;

.(Initial position )

T = ;

.( Translation coordinates)

X =

.( New coordinates)

Thus,

= +
;

X=X+T ;

Rotation :
A two dimensional rotation is rotation of an object about a single point along a circular path
constrained about a given angle..
`A 2-D rotation can also be described as rotation of object about an axis about an axis
perpendicular to xy plane and fixed at the pivot point..

Now in this transformation we take input as the pivot coordinate(x,y) and the angle through
which the object is to be rotated..
Lets first consider (xr,yr) to (0,0)
So according to the above diagram we can form the equations such as ..
x = r*Cos( + ) = () () () () ;

(3)

y = r*Sin( + ) = () () () () ;

(4)

Orignal point ,
x = r*Cos() ;

(5)

y = r*Sin() ;

(6)

Substituting original points is new point equations 3,4 :


x = () () ;

(7)

y = () + () ;

(8)

Thus in matrix form

P= ;
P =
R=

() ()
;
() ()

Here R is the rotation matrix ..

Now for rotaion about some point (x,y) ..


We have to translate the all the points from w.r.t. origin to w.r.t. (xr,yr)
From eqtns 7,8;
Let X,Y be the final coordinates for rotation about (xr,yr)
But x,y are the equation obtained about origin thus there is slight change in the equations while
substituting them below
Thus ,
X = xr + x(w.r.t (xr,yr));
Y = yr + y(w.r.t (xr,yr));
X = xr + (. . (, )) () (. . (, )) () ;
(. . (, )) = ;
Similiarly,
(. . (, )) = y yr ;
Thus, X = xr +( ) () ( ) () ;

(9)

Y = xr +( ) () ( ) () ;

(10)

Expanding the eqn (9),


X = xr ( xr*Cos() yr*Sin() ) + (x*Cos () - y*Sin() ) ;
Y = yr (xr *Sin() + yr*Sin() ) + (x*Sin() +y* Cos() ) ;

Thus,
The matrix form is :
P = Pr - R * Pr + R * P ;

(R-Rotation matrix , Pr Rotation coordinate(Pivot point) )

Scaling :
Scaling transformation alters the size of the object . This operation is carried out by multiplying
the coordinates with scaling factors sx,sy .
Thus equations can be written as ,
x =sx * x;

y =sy * y;

Scaling matrix= S =
0

0
;

P = S * P ;
Any positive values can be assigned to scaling factors sx ,sy .
If sx,sy are less than 1 then the object is shifted close to origin and becomes smaller in size than the
original object ..
And if the factors are greater than 1 then magnification occurs and the object moves away from the
origin..
If the scaling factors are equal in magnitude i.e sx=sy then the condition is called as uniform
scaling..This scaling alters the object in equal relative proportions w.r.t the object..
As the scaling occurs wrt to the origin we can also change the scaling point by using the
modified equations ..
Let the point via which the scaling has to occur be (xs,ys)
Thus,
x = x +xs ;
y = y + ys;
but here x = sx * (x w.r.t xs);
y =sy * (y w.r.t ys);
x = sx(x-xs) + xs ;
y =sy*(y-ys) + ys;

If sx!=sy then non uniform transformation can be caused..That is we can covert a square to a
rectangle by using appropriate scaling transformations..

Potrebbero piacerti anche