0% found this document useful (0 votes)
29 views

2pdf

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views

2pdf

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 64

Unit 2: Two Dimensional

Compiled by: Parash Mani


Bhandari
BCA 5th Semester

1
Transformation
• Changing co-ordinate description of an object is called
transformation.
• Types:
• Rigid body transformation (transformation without change in
shape.)

Compiled by: Parash Mani


Bhandari
• Non rigid body transformation (transformation with change in
shape.)
• When a transformation takes place on a 2D plane, it is called 2D
transformation.
• The three basic transformations are
• Translation
• Rotation
• Scaling
• Other transformation includes reflection and shear. 2
2D Geometric
Transformation

Compiled by: Parash Mani


3

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

Compiled by: Parash Mani


Bhandari
transformations are translation, rotation, and scaling. Other
transformations that are often applied to objects include
reflection and shear. In these all cases we consider the
reference point is origin so if we have to do these
transformations about any point then we have to shift these
point to the origin first and then perform required operation and
then again shift to that position.
4
Basic Transformations
1. Translation

Compiled by: Parash Mani


Bhandari
2. Rotation
3. Scaling
4. Reflection
5. shearing 5
HOMOGENOUS FORM
Expressing position in homogeneous coordinates allows
us to represent all geometric transformations equation as matrix
multiplications.
( x, y) -------------------- (xh, yh ,h)
x= xh /h y= yh /h

Compiled by: Parash Mani


Bhandari
where h is any non zero value
For convenient h=1

(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').

Compiled by: Parash Mani


Bhandari
x’ = x + tx
y’ = y + ty where the pair (tx, ty) is called the translation vector or shift vector.

7
We can write equation as a single matrix equation by using
column vectors to represent coordinate points and translation
vectors. Thus,

Compiled by: Parash Mani


Bhandari
P’ = P + T
So we can write

In homogeneous representation if position P = (x, y) is translated to


new position P’= (x’, y’) then:

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.

Compiled by: Parash Mani


Bhandari
+ Value for ‘θ’ define counter-clockwise rotation about a point
- Value for ‘θ’ defines clockwise rotation about a point

9
Compiled by: Parash Mani
10

Bhandari
Anticlockwise direction

At Origin

Coordinates of point ( x,y ) in polar form


y

Compiled by: Parash Mani


Bhandari
11
In homogeneous co-ordinate
Anticlockwise direction

Compiled by: Parash Mani


Bhandari
Clockwise direction

-
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

Compiled by: Parash Mani


Bhandari
13
Thus, for equation form,
x' = x. sx and
y’ = y. sy

Compiled by: Parash Mani


Bhandari
• Values greater than 1 for sx , s y produce enlargement
• Values less than 1 for sx , s y reduce size of object
• s x = s x = 1 leaves the size of the object unchanged
• When sx , s y are assigned the same value s x = s x = 3 or 4 etc
14
then a Uniform Scaling is produced
P‘= S.P

Compiled by: Parash Mani


15

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.

Compiled by: Parash Mani


Bhandari
When the reflection axis is a line in the xy plane, the rotation
path about this axis is in a plane perpendicular to the xy-plane.
For reflection axes that are perpendicular to the xy-plane, the
rotation path is in 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

Compiled by: Parash Mani


Bhandari
x’ = x
y’ = -y

Homogeneous co-ordinate

17
Reflection
(ii) Reflection about y axis or about line x = 0

Keeps ‘y’ value same but flips x value of


coordinate
points

Compiled by: Parash Mani


Bhandari
x’ = -x
y’ = y

Homogeneous co-ordinate

18
Reflection
(iii) Reflection about origin

Flip both ‘x’ and ‘y’ coordinates of a point

x’ = -x
y’ = -y

Compiled by: Parash Mani


Bhandari
Homogeneous co-ordinate

19
Reflection
(iv) Reflection about line y = x
x’ = y
y’ = x

Compiled by: Parash Mani


Bhandari
Homogeneous co-ordinate Equivalent to:
• Reflection about x-axis
• Rotate anticlockwise 90˚
OR
• Clockwise rotation 45 ˚ 20
• Reflection with x-axis
• anticlockwise rotation 45 ˚
Reflection
(v) Reflection about line y = -x
x’ = -y
y’ = -x

Compiled by: Parash Mani


Bhandari
21
Shearing
It distorts the shape of object in either ‘x’ or ‘y’ or both
direction. In case of single directional shearing (e.g. in ‘x’
direction can be viewed as an object made up of very thin layer
and slid over each other with the base remaining where it is).
Shearing is a non-rigid-body transformation that moves objects

Compiled by: Parash Mani


Bhandari
with deformation.

22
Shearing

Compiled by: Parash Mani


23

Bhandari
Shearing

Compiled by: Parash Mani


24

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)

Compiled by: Parash Mani


Bhandari
Since, the composite transformation such as include many
sequence of translation, rotation etc and hence the many naturally
differ addition & multiplication sequence have to perform by the
graphics allocation. Hence, the applications will take more time for
rendering.
Thus, we need to treat all three transformations in a consistent
way so they can be combined easily & compute with one
mathematical operation. If points are expressed in homogenous
coordinates, all geometrical transformation equations can be
represented as matrix multiplications. 25
Homogenous Coordinates

Compiled by: Parash Mani


26

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.

Compiled by: Parash Mani


Bhandari
27
Homogenous Coordinates
• For translation

With T( tx , ty ) as translation matrix, inverse of this translation matrix is

Compiled by: Parash Mani


Bhandari
obtained by representing tx, ty with -tx, -

• 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

• Reflection about y-axis

• Reflection about y=x-axis

Compiled by: Parash Mani


Bhandari
• Reflection about y=-x-axis

• Reflection about any line y=mx+c

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

Compiled by: Parash Mani


Bhandari
as a concatenation, or composition, of matrices. For column
matrix representation of coordinate positions we form
composite transformation by multiplying matrices in order from
right to left.
Right to Left
A.B ≠ B.A 30
Fixed Point Rotation

Compiled by: Parash Mani


Bhandari
(Xf,Yf)
(Xf,Yf)

31
Fixed Point Rotation
Step 1: The fixed point along with the object is translated to
coordinate origin.

Compiled by: Parash Mani


Bhandari
(Xf,Yf)

32
(Xf,Yf)
Fixed Point Rotation
Step 2: Rotate the objet about origin

Compiled by: Parash Mani


Bhandari
(Xf,Yf)

(Xf,Yf) 33
Fixed Point Rotation
Step 3: The fixed point along with the object is translated back
to its original position.

Compiled by: Parash Mani


Bhandari
(Xf,Yf) (Xf,Yf)

34
Fixed Point Rotation
Original
Image

(Xf,Yf)

Compiled by: Parash Mani


Bhandari
Step 1 Step 2 Step 3
T’x = Translate its
original place

Tx = Translate to origin R θ = Rotate angle θ


(Xf,Yf)
35

(Xf,Yf) (Xf,Yf)
Fixed Point Rotation
Composite Transformation

= T’(Xf ,Yf) . R θ . T(-Xf ,-Yf)

Compiled by: Parash Mani


Bhandari
1 0 Xf Cos θ -Sin θ 0 1 0 -Xf

. .
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

Compiled by: Parash Mani


Bhandari
=

=
.
-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:

Compiled by: Parash Mani


Bhandari
1. Translate the fixed point to origin.
2. Rotate about the origin by specified angle θ .
3. Reverse the translation as performed earlier.

38
Thus, the composite matrix is given by
Com = T(xf, yf) . Rθ .T(-xf, -yf)

Compiled by: Parash Mani


Bhandari
39
Now, the required co-ordinate can be
calculated as:

P’ = Com . P

Compiled by: Parash Mani


Bhandari
Hence, the new required coordinate points are 40
(4, 4), (6, 6) & (6, 2).
Fixed Point Scaling

Compiled by: Parash Mani


Bhandari
(Xf,Yf)
(Xf,Yf)

41
Fixed Point Scaling
Step 1: The fixed point along with the object is translated to
coordinate origin.

Compiled by: Parash Mani


Bhandari
(Xf,Yf)

42
(Xf,Yf)
Fixed Point Scaling
Step 2 : Scaling the objet about origin

Compiled by: Parash Mani


Bhandari
(Xf,Yf)

(Xf,Yf) 43
Fixed Point Scaling
Step 3: The fixed point along with the object is translated back
to its original position.

Compiled by: Parash Mani


Bhandari
(Xf,Yf) (Xf,Yf)

44
Fixed Point Scaling
Original
Image

(Xf,Yf)

Compiled by: Parash Mani


Bhandari
Step 1 Step 2 Step 3
T’x = Translate its
original place
S = Scalig at origin
Tx = Translate to origin

(Xf,Yf)
45

(Xf,Yf) (Xf,Yf)
Fixed Point Rotation
Composite Transformation

= T’(Xf ,Yf) . S(sx,sy) . T(-Xf ,-Yf)

Compiled by: Parash Mani


Bhandari
1 0 Xf Sx 0 0 1 0 -Xf

. .
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

Compiled by: Parash Mani


Bhandari
direction and then translate (3,4) .

Q.N.3.>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 direction and
then translate by 3 unit along x-direction.

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)

Compiled by: Parash Mani


Bhandari
52
Q.N.1 > Reflect an object (2, 3), (4, 3), (4, 5) about line y = x +1.
Solution
Here,
The given line is y = x +1.
Thus,
When x = 0, y=1
When x = 1, y=2

Compiled by: Parash Mani


Bhandari
When x = 2, y=3

(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.

Compiled by: Parash Mani


Bhandari
• Reverse translate the line to original position by adding the y-
intercept with one.

Thus, the composite matrix is given by:


CM=T’(0,C) . R’θ. Rrefl. Rθ . T(0,-C)

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

Compiled by: Parash Mani


Bhandari
57
Hence, the final coordinates are (2, 3), (2, 5) & (4, 5).
Q.N.> Reflect a triangle A(1,8) B(3,8) and C(1,6)
about line y= x+2

Compiled by: Parash Mani


Bhandari
X Y
0 2
1 3
2 4
3 5

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

Compiled by: Parash Mani


Bhandari
Here,
The given mirror or line is
passing through the
points (0, 10) & (10, 0).
Now, the slope of the line
(m) = (y2-y1) / (x2-x1)
= (0 - 10) / (10 - 0) = -1
Thus, the rotation angle (θ) 59
= Tan -1 (m) = Tan -1(-1)
= - 450
The composite matrix is given by:
Com
= T(0, 10) or (10, 0). Rθ in CW .Rfx .R θ in CCW .T(0, -10) or (-10, 0)

Compiled by: Parash Mani


Bhandari
60
Compiled by: Parash Mani
61

Bhandari
Now, the required co-ordinate can be calculated as:
P’ = Com . P

Compiled by: Parash Mani


Bhandari
Hence, the final coordinates are (3, 4), (4, 3) & (1, 4).

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

Compiled by: Parash Mani


Bhandari
angle and last reflect those line on X-axis .
• Digitize x2+y2 = 100 in first octant.

63
Any Queries?

Compiled by: Parash Mani


64

Bhandari

You might also like