Computer Graphics-PPT - CH3
Computer Graphics-PPT - CH3
There are basic five types of transformation that can be applied on any 2D shape.
1) Translation
2) Rotation
3) Scaling
4) Reflection
5) Shear
Translation
Translation is the process of repositioning the object in a straight line path from one
coordinate position to another.
We define the translation vector (tx , ty).
tx defines movement of the object in X – direction and ty defines the movement of the
object in Y-direction.
Assuming point P(X,Y) needs to be translated to position P’(X’,Y’).
This can be obtained by simply adding tx to X and Ty to y
X’= X + tx
Y’ = Y + ty
OR
P’ = P + T where
P = [ X Y ] , P’ = [X’ Y’ ] and T =[tx ty]
Translation
Example:
For a vertex with coordinates (x,y) and a fixed pivot point (xf,yf), the
scaled coordinates (x’,y’) are calculated as,
x’ = xf + (x – xf) .Sx
y’ = yf + (y – yf).Sy
OR
X’ = x . Sx + xf (1-Sx)
Y’ = y . Sy + yf (1-Sy)
EXAMPLE: SCALING
Homogenous Coordinates
Find the transformation matrix that transforms the given square ABCD to half
its size with center still remaining at the same position. The coordinates of the
square are A(1,1), B(3,1), c (3,3) and D (1,3). Also find the resultant
coordinates of square.
Solution
We can generate rotation about any fixed point (called pivot point) (Xr,Yr)
by performing following sequence of Translate – Rotate – Translate.
1) Translate the object so that the pivot point is moved to the coordinate
origin
2) Rotate the object about the origin
3) Translate the object so that the pivot point is returned to its original
position.
Sequence of transformation for rotation w.r.t fixed
point
Fixed point scaling
To scale an object with respect to a selected fixed point (or pivot point)
say (Xf,Yf) perform the following operations.
1) Translate object so that the fixed point coincides with the origin
2) Scale the object with respect to the origin.
3) Use the inverse translation of step (1) to return bring the object
back to its original position.
Sequence of transformations for
scaling w.r.t fixed point
Derivation – Scaling w.r.t fixed point
General Scaling Direction
Consider a square with coordinates as (0,0), (0,1), (1,0) and (1,1). If the above
transformation is applied to the square along a diagonal form (0,0) to (1,1). ,
the square gets turned into a parallelogram as shown in the figure below.
Consider
S1 = 1 and S2 = 2.
Solution: Here we rotate the diagonal onto the Y – axis and double its length with
the transformation parameters θ=45 , s1 = 1 , s2 = 2.
Before After
Reflection
Sequence of transformations
1) Rotate the line y=x by an angle 45 clock
wise so that it coincides with X- Axis.
2) Reflect an object about X- axis
3) Perform inverse rotation
Reflection of an object about Line
Y=-X
Sequence of transformation.
1) Rotate the line Y=-X by an angle 45 in clockwise
direction so that it coincides with the Y – axis.
2) Perform Reflection about Y-axis.
3) Perform the inverse rotation.
Reflection of an object about
arbitrary line y=mx+c (IMP)
[x’ y’ 1] = [ x y 1]
B(2,10)
A(2,3)
Solution (A)
(A) Here θ =90 ( we use row measure)
So R = = After Rotation Original
B(2,10
)
P’ = P . R
B’(-10,2) A’(-3,2)
= A(2,3)
M= =
= =
B c
A
A) First Rotate by 90 degree and then translate with tx=ty=1
M = R(90) . T(1,1)
= Transformed triangle
=
C’
= A’
B’
Now apply this transformation on original points
P’ = P . M
= =
So the triangle after transformation is A’(1,2) , B’(0,1) , C’(0,2)
B) First translate with tx=ty=1 and then Rotate
Transformed triangle
M = T(1,1). R(90) .
=
C’ A’
= B’
=
Now apply this transformation on original points
P’ = P . M
= =
So the triangle after transformation is A’(-1,2) , B’(-2,1) , C’(-2,2)
NOTE: Solve the same problem using theta = 45
HOME WORK
The transformation that is used to alter the size of the object is called
A) Translation
B) Rotation
C) Scaling
D) Reflection
E) All of the above
To change the position of a circle we translate
1) Only center coordinate (i.e. origin)
2) center coordinate and redraw circle in a new location
3) each point on a circle.
4) All of these
Positive value for the rotation angle θ defines
A) counter clockwise rotation of a point
B) Counter clock wise translation a point
C) clock wise rotation of a point
D) clockwise Translation of a point
____________ is a rigid body transformation that moves the object
without deformation
A) Rotation
B) Scaling
C) Transformation
D) All
In geometric transformation
A) Object is moved while back ground is kept stationery or fixed.
B) Background is moved while object is kept stationary
C) Bothe object and Background are moved
D) all
The translation distance (dx,dy) is called
1) Translation vector
2) Shift vector
3) Both (1) and ( 2 )
4) None
End of Chapter 3