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

Ass 4 MOD

The document discusses various text and line clipping algorithms in computer graphics including Cohen-Sutherland and Sutherland-Hodgeman algorithms. It provides definitions of text clipping and lists different text clipping methods. It also describes point clipping, line clipping and polygon clipping. Steps of Cohen-Sutherland line clipping and Sutherland-Hodgeman polygon clipping algorithms are provided.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views

Ass 4 MOD

The document discusses various text and line clipping algorithms in computer graphics including Cohen-Sutherland and Sutherland-Hodgeman algorithms. It provides definitions of text clipping and lists different text clipping methods. It also describes point clipping, line clipping and polygon clipping. Steps of Cohen-Sutherland line clipping and Sutherland-Hodgeman polygon clipping algorithms are provided.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

JSPM’s

JAYAWANTRAO SAWANT POLYTECHNIC, Handewadi


Road, Hadapsar, Pune-28

Department of Information Technology

Academic Year 2023-24


ASSIGNMENT-IV MODEL ANSWER

Subject: Computer Graphics Subject Code: 22318


Course &Code: CO3I Class: SYCO-2
Semester: Third Name of the Faculty: Mrs.S.P.Sabat
Date:

CO 4:Implement various clipping Algorithms.

CHAPTER 4: Windowing and Clipping

Question Marking
Model Answer scheme
No.
1
Define Text Clipping and List Various Text Clipping Methods

Defination
Various techniques are used to provide text clipping in a computer graphics. It01 Marks on the meth
depends

Various
Methods 1
Marks Listing
All or none string clipping
All or none character clipping
Text clipping

2 What is Point Clipping and Line Clipping


Clipping a point from a given window is very easy. Consider the
following figure, where the rectangle indicates the window. Point
clipping tells us whether the given point

X,Y is within the given window or not; and decides whether we will use
the minimum and maximum coordinates of the window.

The X-coordinate of the given point is inside the window, if X lies in between Wx1 X Wx2. Same

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.

333 Use the Cohen Sutherland algorithm to clip two lines P1(35,10)- 4M
P2(65,40) and P3(65,20)-P4(95,10) against a window A(50,10),
B(80,10), C(80,40) and D(50,40).
First Line
2M,Second
Line 2M
4 Describe Sutherland-Hodgeman algorithm for polygon clipping Correct
algorithm 4
In Sutherland-Hodgeman, a polygon is clipped by processing the polygon Marks
boundary as a whole against each window edge. Clipping window must
be convex. This could be accomplished by processing all polygon
vertices against each clip rectangle boundary in turn beginning with the
original set of polygon vertices, first clip the polygon against the left
rectangle boundary to produce a new sequence of vertices. The new set
of vertices could then be successively passed to a right boundary clipper,
a top boundary clipper and a bottom boundary clipper. At each step a
new set of polygon vertices us generated and passed to the next window
boundary clipper. This is the logic used in Sutherland-Hodgeman
algorithm.
Fig. Clipping polygon against successive window boundaries The output
of algorithm is a list of polygon vertices all of which are on the visible
side of clipping plane. Such each edge of the polygon is individually
compared with the clipping plane. This is achieved by processing two
vertices of each edge of the polygon

around the clipping boundary or plane. This results in four possible


relationships between the edge and clipping plane. 1. If first vertex of
polygon edge is outside and second is inside window boundary, then
intersection point of polygon edge with window boundary and second
vertex are added to output vertices set as shown in Fig. 6.13.
Assume that we're clipping a polygon’s edge with vertices at (x1, y1) and
(x2, y2) against a clip window with vertices at (xmin, ymin) and (xmax,
ymax). 1. The location (IX, IY) of the intersection of the edge with the
left side of the window is: (i) IX = xmin (ii) IY = slope*(xmin – x1) +
y1, where the slope = (y2 – y1)/(x2 – x1). 2. The location of the
intersection of the edge with the right side of the window is: (i) IX =
xmax (ii) IY = slope*(xmax – x1) + y1, where the slope = (y2 – y1)/(x2 –
x1) 3. The intersection of the polygon's edge with the top side of the
window is: (i) IX = x1 + (ymax – y1) / slope (ii) IY = ymax 4. Finally,
the intersection of the edge with the bottom side of the window is: (i) IX
= x1 + (ymin – y1) / slope (ii) IY = ymin Algorithm for Sutherland-
Hodgeman Polygon Clipping: Step 1: Read co-ordinates of all vertices of
the polygon. Step 2: Read co-ordinates of the clipping window. Step 3:
Consider the left edge of window. Step 4: Compare vertices of each of
polygon, individually with the clipping plane. Step 5: Save the resulting
intersections and vertices in the new list of vertices according to four
possible relationships between the edge and the clipping boundary. Step
6: Repeat the steps 4 and 5 for remaining edges of clipping window.
Each time resultant list of vertices is successively passed to process next
edge of clipping window. Step 7: Stop.

Write down Cohen-Sutherland Line clipping algorithm Explanation1


M and
Algorithm3 M
Step 1: Scan end points for the line P1(x1, y1) and P2(x2, y2)

Step 2: Scan corners for the window as (Wx1, Wy1) and (Wx2, Wy2)
Step 3: Assign the region codes for endpoints P1 and P2 by

Bit 1 - if (x < Wx1)

Bit 2 - if (x < Wx2)

Bit 3 - if (x < Wy2)

Bit 4 - if (x < Wy1)

Step 4: Check for visibility of line P1, P2 If region codes for both end
points are zero then the line is visible, draw it and jump to step 9.
5
If region codes for end points are not zero and the logical and operation
of them is also not zero then the line is invisible, reject it and jump to
step 9.

If region codes for end points does not satisfies the condition in 4(i) and
4(ii) then line is partly visible.

Step 5: Determine the intersecting edge of the clipping window by


inspecting the region codes for endpoints. If region codes for both the
end points are non-zero, find intersection points P1 and P2 with boundary
edges of clipping window with respect to point P1 and P2. If region code
for any one end point is non zero then find intersection point P1 or P2
with the boundary edge of the clipping window with respect to it.

Step 6: Divide the line segments by considering intersection points.

Step 7: Reject the line segment if any of the end point of it appear outside
the window. Step 8: Draw the remaining line. Step 9: Exit

Subject teacher HOD

You might also like