UNIT - 2 Two Dimensional Geometric Transformations
UNIT - 2 Two Dimensional Geometric Transformations
Geometric
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
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.
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.
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
6
Device Coordinates
2D Coordinate System..
7
2D Geometric
Transformation
8
(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').
12
1. Translation
We can write equation as a single matrix equation by using
column vectors to represent coordinate points and translation
vectors. Thus,
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.
14
Nipun Thapa-Computer Graphics
15
Anticlockwise direction
2. ROTATION
At Origin
-
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
21
4. 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
22
4. Reflection
(ii) Reflection about y axis or about line x = 0
Homogeneous co-ordinate
23
4. Reflection
(iii) Reflection about origin
x’ = -x
Homogeneous co-ordinate
24
4. Reflection
(iv) Reflection about line y = x
x’ = y
y’ = x
27
5. Shearing
• 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
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
36
Fixed Point Rotation
Step 1: The fixed point along with the object is translated to
coordinate origin.
37
(Xf,Yf)
Fixed Point Rotation
Step 2: Rotate the objet about origin
(Xf,Yf) 38
Fixed Point Rotation
Step 3: The fixed point along with the object is translated back
to its original position.
39
Fixed Point Rotation
Original
Image
(Xf,Yf)
(Xf,Yf) (Xf,Yf)
Fixed Point Rotation
Composite Transformation
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
=
.
[ ]
-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:
43
Thus, the composite matrix is given by
Com = T(xf, yf) . Rθ .T(-xf, -yf)
P’ = Com . P
46
Fixed Point Scaling
Step 1: The fixed point along with the object is translated to
coordinate origin.
47
(Xf,Yf)
Fixed Point Scaling
Step 2 : Scaling the objet about origin
(Xf,Yf) 48
Fixed Point Scaling
Step 3: The fixed point along with the object is translated back
to its original position.
49
Fixed Point Scaling
Original
Image
(Xf,Yf)
(Xf,Yf)
50
(Xf,Yf) (Xf,Yf)
Fixed Point Rotation
Composite Transformation
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)
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
Also,
The slope of the line (m) = 1 59
60
Nipun Thapa-Computer Graphics
61
Nipun Thapa-Computer Graphics
62
Now, the required co-ordinate can be calculated as:
P’ = Com x P
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
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).
69