0% found this document useful (0 votes)
118 views69 pages

UNIT - 2 Two Dimensional Geometric Transformations

The document discusses two dimensional geometric transformations. It describes 2D coordinate systems including modeling coordinates, world coordinates, viewing coordinates, and device coordinates. It then explains the basic 2D geometric transformations of translation, rotation, scaling, and reflection. Translation moves an object by adding amounts to x and y coordinates. Rotation rotates an object around a pivot point by a specified angle. Scaling enlarges or shrinks an object by multiplying x and y values. Reflection produces a mirror image of an object across reflection axes like the x-axis, y-axis, or origin.
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)
118 views69 pages

UNIT - 2 Two Dimensional Geometric Transformations

The document discusses two dimensional geometric transformations. It describes 2D coordinate systems including modeling coordinates, world coordinates, viewing coordinates, and device coordinates. It then explains the basic 2D geometric transformations of translation, rotation, scaling, and reflection. Translation moves an object by adding amounts to x and y coordinates. Rotation rotates an object around a pivot point by a specified angle. Scaling enlarges or shrinks an object by multiplying x and y values. Reflection produces a mirror image of an object across reflection axes like the x-axis, y-axis, or origin.
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/ 69

Two Dimensional

Geometric

Nipun Thapa (Computer Graphics)


Transformations

1
Two Dimensional Viewing
• Two-dimensional viewing is the mechanism for displaying
views of a picture on an output device. Much like what we see
in real life through a small window on the wall or the
viewfinder of a camera, a computer-generated image often
depicts a partial view of a large scene. For a 2-D picture, a

Nipun Thapa (Computer Graphics)


view is selected by specifying a subarea of the total picture
area.

2
2D Coordinate System
1. Modeling Coordinates
• Modeling coordinates are used to construct shape of individual parts
(objects or structures) of a 2D scene. For example, generating a circle
at the origin with a “radius” of 2 units.
• Here, origin (0, 0), and radius 2 units are modeling coordinates.

Nipun Thapa (Computer Graphics)


• Modeling coordinates define object shape.
• Can be floating-point, integers and can represent units like km, m,
miles, feet etc.

View Coordinates Device Coordinates


3
2D Coordinate System..
2. World Coordinates
• World coordinates are used to organize the individual parts
into a scene.
• World coordinates units define overall scene to be modeled.

Nipun Thapa (Computer Graphics)


• World coordinates represent relative positions of objects.
• Can be floating-point, integers and can represent units like km,
m, miles etc.

4
2D Coordinate System..
3. Viewing Coordinates
• Viewing coordinates are used to define particular view of the user.
Viewer‟s position and view angle i.e. rotated/translated.
• Viewing coordinates specify the portion of the output device that is
to be used to present the view.

Nipun Thapa (Computer Graphics)


• Normalized viewing coordinates are viewing coordinates between 0
and 1 in each direction. They are used to make the viewing process
independent of the output device (paper, mobile).

5
View Coordinates
2D Coordinate System..
4. Device Coordinates or Screen Coordinates
• The display coordinate system is called device coordinate
system. Device coordinates are specific to output device.
• Device coordinates are integers within the range (0, 0) to

Nipun Thapa (Computer Graphics)


(xmax, ymax) for a particular output device.

6
Device Coordinates
2D Coordinate System..

Nipun Thapa (Computer Graphics)


View Coordinates Device Coordinates

7
2D Geometric
Transformation
8

Nipun Thapa-Computer Graphics


Introduction
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

Nipun Thapa-Computer Graphics


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.
9
Introduction
Basic Transformations
1. Translation

Nipun Thapa-Computer Graphics


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

Nipun Thapa-Computer Graphics


x= xh /h y= yh /h
where h is any non zero value
For convenient h=1

(x,y)-------------------------(x, y, 1).
11
1. Translation
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').

Nipun Thapa-Computer Graphics


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

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

Nipun Thapa-Computer Graphics


P’ = P + T
So we can write

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


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

13
2. ROTATION
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.

Nipun Thapa-Computer Graphics


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

14
Nipun Thapa-Computer Graphics
15
Anticlockwise direction

2. ROTATION
At Origin

Coordinates of point ( x,y ) in polar form

Nipun Thapa-Computer Graphics


16
2. ROTATION
In homogeneous co-ordinate
Anticlockwise direction

Nipun Thapa-Computer Graphics


Clockwise direction

-
17
3.Scaling
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

Nipun Thapa-Computer Graphics


18
3.Scaling
Thus, for equation form,
x' = x. sx and
y’ = y. sy

Nipun Thapa-Computer Graphics


• 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 y = 1 leaves the size of the object unchanged
• When sx , s y are assigned the same value s x = s y = 3 or 4 etc 19
then a Uniform Scaling is produced
P‘= S.P
3.Scaling

Nipun Thapa-Computer Graphics


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

Nipun Thapa-Computer Graphics


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.

21
4. Reflection
(i) Reflection about x axis or about line y = 0

x
Keeps value same but flips Y value of
coordinate points

Nipun Thapa-Computer Graphics


x’ = x
y’ = -y

Homogeneous co-ordinate

22
4. Reflection
(ii) Reflection about y axis or about line x = 0

Keeps ‘y’ value same but flips x value of


coordinate
points

Nipun Thapa-Computer Graphics


x’ = -x
y’ = y

Homogeneous co-ordinate

23
4. Reflection
(iii) Reflection about origin

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

x’ = -x

Nipun Thapa-Computer Graphics


y’ = -y

Homogeneous co-ordinate

24
4. Reflection
(iv) Reflection about line y = x
x’ = y
y’ = x

Nipun Thapa-Computer Graphics


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

Nipun Thapa-Computer Graphics


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

Nipun Thapa-Computer Graphics


with deformation.

27
5. Shearing

Nipun Thapa-Computer Graphics


28
5. Shearing

Nipun Thapa-Computer Graphics


29
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)

Nipun Thapa-Computer Graphics


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. 30
Homogenous Coordinates

Nipun Thapa-Computer Graphics


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

Nipun Thapa-Computer Graphics


32
Homogenous Coordinates
• For translation

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

Nipun Thapa-Computer Graphics


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.
33
• For scaling

• For Reflection
• Reflection about x-axis

• Reflection about y-axis

• Reflection about y=x-axis

Nipun Thapa-Computer Graphics


• Reflection about y=-x-axis

• Reflection about any line y=mx+c

34
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

Nipun Thapa-Computer Graphics


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 35
Fixed Point Rotation

Nipun Thapa-Computer Graphics


(Xf,Yf)
(Xf,Yf)

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

Nipun Thapa-Computer Graphics


(Xf,Yf)

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

Nipun Thapa-Computer Graphics


(Xf,Yf)

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

Nipun Thapa-Computer Graphics


(Xf,Yf) (Xf,Yf)

39
Fixed Point Rotation
Original
Image

(Xf,Yf)

Nipun Thapa-Computer Graphics


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

Tx = Translate to origin R θ = Rotate angle θ


(Xf,Yf)
40

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

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

Nipun Thapa-Computer Graphics


= [ ][ ][ ]
1

0
0

0
Xf

Yf

1
.
Cos θ -Sin θ

Sin θ Cos θ

0 0 1
0
0
.
1

0
0

0
-Xf

-Yf

1
41
Exercise 1
Q. N. > Rotate the triangle (5, 5), (7, 3), (3, 3) in counter
clockwise (CCW) by 90 degree.
A:
P’ = R. P

Nipun Thapa-Computer Graphics


=

=
.

[ ]
-5 -3 -3 42
= 5 7 3

1 1 1
Exercise 2
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:

Nipun Thapa-Computer Graphics


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

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

Nipun Thapa-Computer Graphics


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

P’ = Com . P

Nipun Thapa-Computer Graphics


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

Nipun Thapa-Computer Graphics


(Xf,Yf)
(Xf,Yf)

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

Nipun Thapa-Computer Graphics


(Xf,Yf)

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

Nipun Thapa-Computer Graphics


(Xf,Yf)

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

Nipun Thapa-Computer Graphics


(Xf,Yf) (Xf,Yf)

49
Fixed Point Scaling
Original
Image

(Xf,Yf)

Nipun Thapa-Computer Graphics


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

(Xf,Yf)
50

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

= T’(Xf ,Yf) . Saxix . T(-Xf ,-Yf)

Nipun Thapa-Computer Graphics


= [ ][ ][ ]
1

0
0

0
Xf

Yf

1
.
Sx

0
0

Sy

0 1
0
0
.
1

0
0

0
-Xf

-Yf

1
51
Exercise 2
Q.N.1. > Find the coordinate of a triangle A(1,3) , B(2,5) and C(3,3)
after twice its original size
a) about origin
b)about fixed point (2,3)
Q.N.2. > Find the coordinate of a triangle A(1,3) , B(2,5) and C(3,3)

Nipun Thapa-Computer Graphics


after being rotated about fixed point p(2,4) by 45 in clockwise
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 52
line.
1.Find the coordinate of a triangle (5, 5), (7, 3), (3, 3) after
translate (1,0) then scaling (3,3) then rotate 45 CW then
translate (1,1) and then reflect x=0 line.
2.Find the coordinate of a line (5, 5), (3, 3) after rotate 450
ccw at fixed point (3,3) then translate (1,1) then reflect at
x-axis.
3.Find the coordinate of a point (5, 5) after reflection y-axis

Nipun Thapa (Computer Graphics)


then scaling twice then rotate 30 CW then rotate 300 CW
at fixed point (3,4)
4. Draw a circle at (3,4) with radius 10.
5.Draw an ellipse where x-radius is 6 and y-radius is 8 at
center (0,0)
6.Digitize the line (1,10) and (10,9) using BLA.
7.Clipping the line A(1,5) and B(20,55) where windows has 53
P1(5,5) and P2(50,50).
Reflection about Line y=mx+c

Nipun Thapa-Computer Graphics


54
Reflection about Line y=mx+c

Nipun Thapa-Computer Graphics


55
Reflection about Line y=mx+c

Nipun Thapa-Computer Graphics


56
Reflection about Line y=mx+c

Nipun Thapa-Computer Graphics


57
Reflection about Line y=mx+c

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

Nipun Thapa-Computer Graphics


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

Nipun Thapa-Computer Graphics


Thus,
When x = 0, y=1
When x = 1, y=2
When x = 2, y=3

Also,
The slope of the line (m) = 1 59

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.

Nipun Thapa-Computer Graphics


• 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)

60
Nipun Thapa-Computer Graphics
61
Nipun Thapa-Computer Graphics
62
Now, the required co-ordinate can be calculated as:
P’ = Com x P

Nipun Thapa-Computer Graphics


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

Nipun Thapa-Computer Graphics


X Y
0 2
1 3
2 4
3 5

64
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

Nipun Thapa-Computer Graphics


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 (θ) 65
= 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)

Nipun Thapa-Computer Graphics


66
Nipun Thapa-Computer Graphics
67
Now, the required co-o ed as:
P’ = Com . P

Nipun Thapa-Computer Graphics


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

68
Home Work
• What do you mean by homogeneous coordinates? Rotate a
triangle A(5,6), B(6,2) and C(4,1) by 45 degree about an
arbitrary pivot point (3,3). (2072 TU).
• Use Bresenham's algorithm to draw a line having end points
(25, 20) and (15, 10). (2072 TU).

Nipun Thapa-Computer Graphics


• Given a clipping window P(0,0), Q(30,20), S(0,20) use the
Cohen Sutherland algorithm to determine the visible portion
of the line A(10,30) and B(40,0). (2072 TU)

69

You might also like