0% found this document useful (0 votes)
24 views33 pages

Graphics Note 3

Uploaded by

Technical Dipesh
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)
24 views33 pages

Graphics Note 3

Uploaded by

Technical Dipesh
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/ 33

Unit 3: Two-Dimensional Geometric Transformations (5 Hrs.

)
3.1 Two-Dimensional translation, Rotation, Scaling, Reflection and Shearing
3.2 Homogeneous Coordinate and 2D Composite Transformations.
Transformation between Co-ordinate Systems.
3.3 Two Dimensional Viewing: Viewing pipeline, Window to viewport coordinate
transformation
3.4 Clipping: Point, Lines (Cohen Sutherland line clipping, Liang-Barsky Line
Clipping) ,Polygon Clipping(Sutherland Hodgeman polygon clipping)

1
2
3
4
5
6
7
8
9
10
11
12
Two Dimensional Viewing: Viewing pipeline, Window to viewport coordinate
transformation:

13
Windows are areas on screen where graphical information can be displayed View
ports refer to rectangular areas inside window that display graphical data. View
ports are or can be of different sizes but are always smaller than size if window.
For practical applications we need a transformation to translate and scale window
to any size by moving it to specified rectangular area on screen This area is
commonly called the view port The choice of window decides what we want to
see on display and choice of view port decides where we want to see on display
screen. This concept allows user to divide screen into virtual partitions.

The display hardware divides screen into a number of pixels arranged in a grid
with each pixel are associated its x , y coordinates. Top left corner of screen is
called origin of coordinate system Value of 'x' coordinate increases from left to
right Value of 'y' coordinate increases from top towards bottom. These
coordinates are reference d to as device for screen coordinates. For the VGA
graphics card the size of display grid is 640 x 480. Similarly suitable coordinate
system can be selected for objective in space The coordinates so defined are
world coordinates It may sometimes be desirable to select a part of object or
drawing for display in order to obtain sufficient detail of the object on display The
part of interest is enclosed n a rectangular boundary called a window For
displaying one has to convert world coordinates into screen coordinates This
transformation is called viewing transformation In general view transformation
consists of operations such as scaling, translation , rotation etc.
Window to View Port Transformation (2-D Viewing Transformation Pipeline).

14
Clipping:

15
1. Point clipping:

2. Line clipping:
The concept of line clipping is same as point clipping. In line clipping, we will cut
the portion of line which is outside of window and keep only the portion that is
inside the window.
This algorithm uses the clipping window as shown in the following figure. The
minimum coordinate for the clipping region is (XWmin,YWmin)(XWmin,YWmin)
and the maximum coordinate for the clipping region is
(XWmax,YWmax)(XWmax,YWmax).

16
We will use 4-bits to divide the entire region. These 4 bits represent the Top,
Bottom, Right, and Left of the region as shown in the following figure. Here, the
TOP and LEFT bit is set to 1 because it is the TOP-LEFT corner.

There are 3 possibilities for the line −


 Visible line: Line can be completely inside the window (This line should be
accepted).
 Invisible line: Line can be completely outside of the window (This line will
be completely removed from the region).

17
 Candidate line: Line can be partially inside the window (We will find
intersection point and draw only that portion of line that is inside region).

18
19
20
Advantage of Cohen Sutherland Line Clipping:
 It calculates end-points very quickly and rejects and accepts lines quickly.
 It can clip pictures much large than screen size.

21
22
23
24
25
Do this………..
Liang-Barsky Line Clipping Algorithm:
The algorithm was introduced by “You-Dong Liang” and “Brian A. Barsky.” It is
used for line clipping. It is a more powerful algorithm than the Cohen-Sutherland
algorithm.

We use the following concepts in this algorithm-


 We can use the parametric equation of line and inequalities.
 These are used to describe the range of windows to find out the
intersection points between the line and the clipping window.
 The parametric line is also known as “Cyrus-Beck.”
In this algorithm, we have to find the intersection point based on a time interval.

Time interval (t) can be defined as travelling time between initial position (0) to
final position (1). Then we have,

26
Algorithm of Liang-Barsky Line Clipping:

27
28
29
30
Advantages
1. More efficient than other algorithms as line intersection with boundaries
calculations are reduced.
2. Intersections of line are computed only once.
Polygon Clipping (Sutherland Hodgman Algorithm):

31
A polygon can also be clipped by specifying the clipping window. Sutherland
Hodgeman polygon clipping algorithm is used for polygon clipping. In this
algorithm, all the vertices of the polygon are clipped against each edge of the
clipping window.
First the polygon is clipped against the left edge of the polygon window to get
new vertices of the polygon. These new vertices are used to clip the polygon
against right edge, top edge, bottom edge, of the clipping window as shown in the
following figure.

While processing an edge of a polygon with clipping window, an intersection


point is found if edge is not completely inside clipping window and the a
partial edge from the intersection point to the outside edge is clipped. The
following figures show left, right, top and bottom edge clippings –
Four possible situations while processing
1. If the first vertex is an outside the window, the second vertex is inside the
window. Then second vertex is added to the output list. The point of intersection
of window boundary and polygon side (edge) is also added to the output line.
2. If both vertexes are inside window boundary. Then only second vertex is added
to the output list.
3. If the first vertex is inside the window and second is an outside window. The
edge which intersects with window is added to output list.
4. If both vertices are the outside window, then nothing is added to output list.

32
Disadvantage of Cohen Hodgmen Algorithm:

This method requires a considerable amount of memory. The first of all polygons
are stored in original form. Then clipping against left edge done and output is
stored. Then clipping against right edge done, then top edge. Finally, the bottom
edge is clipped. Results of all these operations are stored in memory. So wastage
of memory for storing intermediate polygons.

33

You might also like