2pdf
2pdf
1
Transformation
• Changing co-ordinate description of an object is called
transformation.
• Types:
• Rigid body transformation (transformation without change in
shape.)
Bhandari
Basic Transformations
The orientation, size, and shape of the output primitives
are accomplished with geometric transformations that alter the
coordinate descriptions of objects. The basic geometric
(x,y)-------------------------(x, y, 1).
6
A translation is applied to an object by repositioning it
along a straight-line path from one coordinate location to
another. We translate a two-dimensional point by adding
translation distances, tx, and ty, to the original coordinate
position (x, y) to move the point to a new position (x ' , y').
7
We can write equation as a single matrix equation by using
column vectors to represent coordinate points and translation
vectors. Thus,
8
A two-dimensional rotation is applied to an object by
repositioning it along a circular path in the xy plane. To generate
a rotation, we specify a rotation angle θ and the position (xr , yr)
of the rotation point (or pivot point) about which the object is to
be rotated.
9
Compiled by: Parash Mani
10
Bhandari
Anticlockwise direction
At Origin
-
12
A scaling transformation alters the size of an object. This
operation can be carried out for polygons by multiplying the coordinate
values (x, y) of each vertex by scaling factors sx and sy to produce the
transformed coordinates (x', y').
• sx scales object in ‘x’ direction
• sy scales object in ‘y’ direction
Bhandari
Reflection
A reflection is a transformation that produces a mirror
image of an object. The mirror image for a 2D reflection is
generated relative to an axis of reflection by rotating the object
180" about the reflection axis. We can choose an axis of
reflection in the xy-plane or perpendicular to the xy plane.
16
Reflection
(i) Reflection about x axis or about line y = 0
x
Keeps value same but flips Y value of
coordinate points
Homogeneous co-ordinate
17
Reflection
(ii) Reflection about y axis or about line x = 0
Homogeneous co-ordinate
18
Reflection
(iii) Reflection about origin
x’ = -x
y’ = -y
19
Reflection
(iv) Reflection about line y = x
x’ = y
y’ = x
22
Shearing
Bhandari
Shearing
Bhandari
Homogenous Coordinates
The matrix representations for translation, scaling and rotation
are respectively:
• Translation: P’ = T + P (Addition)
• Scaling: P’ = S . P (Multiplication)
• Rotation: P’ = R . P (Multiplication)
Bhandari
Homogenous Coordinates
Here, in case of homogenous coordinates we add a third
coordinate ‘h’ to a point (x, y) so that each point is represented
by (hx, hy, h). The ‘h’ is normally set to 1. If the value of ‘h’ is
more the one value then all the co-ordinate values are scaled by
this value.
• For rotation
Here, figure-a shows the Counter Clockwise (CCW) rotation & figure-b
shows the Clockwise (CW) rotation.
28
• For scaling
• For Reflection
• Reflection about x-axis
29
Composite Transformation
With the matrix representation of transformation
equations it is possible to setup a matrix for any sequence of
transformations as a composite transformation matrix by
calculating the matrix product of individual transformation.
Forming products of transformation matrices is often referred to
31
Fixed Point Rotation
Step 1: The fixed point along with the object is translated to
coordinate origin.
32
(Xf,Yf)
Fixed Point Rotation
Step 2: Rotate the objet about origin
(Xf,Yf) 33
Fixed Point Rotation
Step 3: The fixed point along with the object is translated back
to its original position.
34
Fixed Point Rotation
Original
Image
(Xf,Yf)
(Xf,Yf) (Xf,Yf)
Fixed Point Rotation
Composite Transformation
. .
0 1 Yf Sin θ Cos θ 0 0 1 -Yf
= 0 0 1 0 0 1 0 0 1
36
Q. N. > Rotate the triangle (5, 5), (7, 3), (3, 3) in counter
clockwise (CCW) by 90 degree.
A:
P’ = R. P
=
.
-5 -3 -3
= 5 7 3 37
1 1 1
Q.>Rotate the triangle (5, 5), (7, 3), (3, 3) about fixed point (5, 4)
in counter clockwise (CCW) by 90 degree.
A : Solution
Here, the required steps are:
38
Thus, the composite matrix is given by
Com = T(xf, yf) . Rθ .T(-xf, -yf)
P’ = Com . P
41
Fixed Point Scaling
Step 1: The fixed point along with the object is translated to
coordinate origin.
42
(Xf,Yf)
Fixed Point Scaling
Step 2 : Scaling the objet about origin
(Xf,Yf) 43
Fixed Point Scaling
Step 3: The fixed point along with the object is translated back
to its original position.
44
Fixed Point Scaling
Original
Image
(Xf,Yf)
(Xf,Yf)
45
(Xf,Yf) (Xf,Yf)
Fixed Point Rotation
Composite Transformation
. .
0 1 Yf 0 Sy 0 0 1 -Yf
= 0 0 1 0 0 1 0 0 1
46
Q.N.1. > Find the coordinate of a triangle A(1,3) , B(2,5) and C(3,3)
after twice its original size about fixed point (2,3)
Q.N.2. > Find the coordinate of a triangle A(1,3) , B(2,5) and C(3,3)
after being rotated about fixed point p(2,4) by 45 in clockwise
Q.N.4 >Find the coordinate of a triangle (5, 5), (7, 3), (3, 3) after scaling
(2,3) and then rotate 45 CCW then translate (1,1) and then reflect y=0 47
line.
Compiled by: Parash Mani
48
Bhandari
Compiled by: Parash Mani
49
Bhandari
Compiled by: Parash Mani
50
Bhandari
Compiled by: Parash Mani
51
Bhandari
CM=T’(0,C) . R’θ. Rrefl. Rθ . T(0,-C)
(0,1)
(C=1)
Also, (0,0)
The slope of the line (m) = 1 53
Thus, the rotation angle (θ) = Tan-1(m) = Tan-1(1) = 450
Here, the required steps are:
• Translate the line to origin by decreasing the y-intercept with
one.
• Rotate the line by angle 450 in clockwise direction so that the
given line must overlap x-axis.
• Reflect the object about the x-axis.
• Reverse rotate the line by angle -450 in counter-clockwise
direction.
54
Compiled by: Parash Mani
55
Bhandari
Compiled by: Parash Mani
56
Bhandari
Now, the required co-ordinate can be calculated as:
P’ = Com x P
58
Exercise (Imp)
Q.N> A mirror is placed such that it passes through (0,10),
(10, 0). Fin the mirror image of an object (6,7), (7, 6), (6, 9).
Solution
Bhandari
Now, the required co-ordinate can be calculated as:
P’ = Com . P
62
• Rotate a triangle A(5,6), B(6,2) and C(4,1) by 45 degree about
an arbitrary pivot point (3,3).
• Find the coordinate of a line A(1,2) ,B(3,3) after translate (2,2)
then rotate 35o angle clockwise and then again translate the
line on (-2,-2) and rotate Counter clockwise direction of 35o
63
Any Queries?
Bhandari