Upcoming SlideShare
×

# Clipping2

1,550 views

Published on

Published in: Technology, Art & Photos
1 Like
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

Views
Total views
1,550
On SlideShare
0
From Embeds
0
Number of Embeds
7
Actions
Shares
0
106
0
Likes
1
Embeds 0
No embeds

No notes for slide

### Clipping2

1. 1. Polygon Clipping <ul><li>When a closed polygon is clipped as a collection of lines, the original closed polygon becomes one or more open polygons or discrete lines . </li></ul><ul><li>For polygon clipping we require an algorithm that will generate one or more closed areas. </li></ul><ul><li>The output of a polygon clippers be a sequence of vertices that defines the clipped polygon boundary. </li></ul>
2. 2. Sutherland Hodgeman Algorithm <ul><li>We can correctly clip a polygon by processing a polygon boundary as a whole against each window edge. </li></ul><ul><li>This could be accomplished by processing all polygon vertices against each clip rectangle boundary. </li></ul><ul><li>Beginning with the initial set of polygon vertices, we could first clip against the left rectangle boundary to procedure a new sequence of vertices. </li></ul>
3. 3. Sutherland Hodgeman Algorithm <ul><li>The new set of vertices could than be successively passed to a right boundary clipper, a bottom boundary clipper, & a top boundary clipper. </li></ul><ul><li>At each step a new sequence of output vertices is generated & passed to the next window boundary clipper. </li></ul><ul><li>These are four possible cases when processing vertices in sequence around the perimeter of a polygon. </li></ul>
4. 4. Sutherland Hodgeman Algorithm Left Clipper Right Clipper Bottom Clipper Top Clipper
5. 5. Sutherland Hodgeman Algorithm <ul><li>As each pair of adjacent polygon vertices is passed to a window boundary clipper we make the following tests. </li></ul><ul><li>* If the first vertex is outside the window boundary </li></ul><ul><li>& the second vertex is inside, the intersection </li></ul><ul><li>point of the polygon edge with the window </li></ul><ul><li>boundary & the second vertex are added </li></ul><ul><li>to the output vertex list. </li></ul>V1 V2 V1’ Out – In Save V1’, V2
6. 6. Sutherland Hodgeman Algorithm <ul><li>* If both input vertices are inside the window </li></ul><ul><li>boundary only the second vertex is added to the </li></ul><ul><li>output vertex list. </li></ul>V1 V2 In – Out Save V2
7. 7. Sutherland Hodgeman Algorithm <ul><li>* If the vertex is inside the window boundary & the second vertex is outside; only the edge intersection with the window boundary is added to the output vertex list </li></ul>V1 V2 In – Out Save V2’ V2’
8. 8. Sutherland Hodgeman Algorithm <ul><li>* If both input vertices are outside the window boundary, nothing is added to the output list. </li></ul>V1 V2 Save None
9. 9. Sutherland Hodgeman Algorithm <ul><li>Left Edge List </li></ul><ul><li>a’bcdefghii’ </li></ul><ul><li>Right Edge List </li></ul><ul><li>bcdd’e’fghii’a’ </li></ul><ul><li>Bottom Edge List </li></ul><ul><li>cdd’e’ff’h’ii’a’b </li></ul><ul><li>Top Edge List </li></ul><ul><li>c’dd’e’ff’h’ii’a’bb’ </li></ul>a a’ b b’ c c’ d d’ e e’ f f’ g h h’ i i’
10. 10. Sutherland Hodgeman Algorithm <ul><li>Convex polygon are correctly clipped by the Sutherland-Hodgeman algorithm but concave polygon may be displayed with extraneous lines. </li></ul><ul><li>This is occur when the clipped polygon should have two or more separate section. </li></ul><ul><li>Since there is only one output vertex list, the last vertex in the list is always joined to the first vertex list </li></ul>
11. 11. Weiler-Atherlton Polygon Clipping <ul><li>In this method, vertex processing procedures for window boundaries are modified so that concave polygons are displayed correctly. </li></ul><ul><li>This clipping procedure was developed as a method for identifying visible surfaces, & so it can be applied with arbitrary polygon clipping regions. </li></ul><ul><li>The basic idea in this algorithm is that instead of always processing around the polygon edges as vertices are processed, we some times want to follow the window boundaries. </li></ul>
12. 12. Weiler-Atherlton Polygon Clipping <ul><li>Which path we follow depends on the polygon processing directions (clockwise or counter clockwise) & whether the pair of polygon vertices currently being processed represented an outside to inside pair or an inside to outside pair. </li></ul><ul><li>For an outside to inside pair of vertices, follow the polygon boundary. </li></ul><ul><li>For an inside to outside pair of vertices, follow the window boundary in a clockwise direction. </li></ul>
13. 13. Weiler-Atherlton Polygon Clipping <ul><li>Concave Polygon </li></ul>V1 V1’ V2 V3 V3’ V4 V4’ V5 V5’ V6
14. 14. Weiler-Atherlton Polygon Clipping c1 c2 c3 c4 s1 s2 s3 s4 s5 s6 s7 I1 I2 I3 I4 I5 I6 I7 I8 Subject Polygon Clip Polygon
15. 15. Weiler-Atherlton Polygon Clipping <ul><li>Subject Polygon List Clip Polygon List </li></ul><ul><li>s1 c1 </li></ul><ul><li>I2 I1 </li></ul><ul><li>I3 I2 </li></ul><ul><li>s2 c2 </li></ul><ul><li>I4 I3 </li></ul><ul><li>s3 I4 </li></ul><ul><li>I5 c3 </li></ul><ul><li>s4 I5 </li></ul><ul><li>I6 I6 </li></ul><ul><li>I7 c4 </li></ul><ul><li>s5 I7 </li></ul><ul><li>I8 I8 </li></ul><ul><li>s6 c1 </li></ul><ul><li>I1 </li></ul><ul><li>s7 </li></ul><ul><li>s1 </li></ul>