Upcoming SlideShare
×

# Polygon clipping

8,567 views

Published on

Computer Graphics

Published in: Education
4 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
Your message goes here
• Be the first to comment

Views
Total views
8,567
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
440
0
Likes
4
Embeds 0
No embeds

No notes for slide

### Polygon clipping

1. 1. •Clipping Any procedure which identifies that portion of a picture which is either inside or outside a picture is referred toas a clipping algorithm or clipping.In geometry a polygon is a flat shape consisting of straightlines that are joined to form a circuit. A polygon istraditionally a plane figure that is bounded by a closedpath, composed of a finite sequence of straight linesegments (i.e., by a closed polygonal chain). Thesesegments are called its edges or sides, and the pointswhere two edges meet are the polygons vertices. Theinterior of the polygon is sometimes called its body.
2. 2. The region against which an object is to beclipped is called clipping window.Clipping is required to specify a localized viewalong with the convenience and the flexibility ofusing a window ,because objects in the scene maybe completely inside the window, completelyoutside the window, or partially visible throughthe window. The Clipping operation eliminatesobjects or portions of objects that are not visiblethrough the window to ensure the paperconstruction image.
3. 3. •Polygon ClippingA polygon boundary processed with a line clipper may bedisplayed as a series of unconnected line segments,depending onthe orientation of the polygon to the clipping window. What wereally want to display is a bounded area after clipping. Forpolygon clipping, we require an algorithm that will generate oneor more closed areas that are then scan converted for theappropriate area fill. The output of a polygon clipper should be asequence of vertices that defines the clipped polygonboundaries.In 2D graphics for example, if the user of an image editingprogram is modifying an image and has "zoomed in" the view todisplay only the top half of the image, there is no need for theprogram to spend any CPU time doing any of the calculations ormemory moves needed to display the bottom half. By clippingthe bottom half of the image and avoiding these calculations, theprogram runs faster.
4. 4. •Sutherland–Hodgeman algorithmThe Sutherland–Hodgeman algorithm is used for clippingpolygons. It works by extending each line of the convex clippolygon in turn and selecting only vertices from the subjectpolygon that are on the visible sideInput each edge (vertex pair) successively.Output is a new list of vertices.Each edge goes through 4 clippers.The rule for each edge for each clipper is: If first input vertex is outside, and second is inside, output the intersection and the second vertex If first both input vertices are inside, then just output second vertex If first input vertex is inside, and second is outside, output is the intersection If both vertices are outside, output is nothing
5. 5. v1 v1’ v1” v3’ v3 v3” v2 v2 Note: Need to consider each of 4 edge boundaries
6. 6. outside inside outside inside outside inside outside inside v2 v2 v2 v2 v1’ v1’ v1 v1 v1 v1Outside to inside: Inside to inside: Inside to outside: Outside to outside:Output: v1’ and v2 Output: v2 Output: v1’ Output: nothing
7. 7. v2’ v2 Figure 6-27, page 332v3 v1’ v3’ Left Right Bottom Top v1 Clipper Clipper Clipper Clipper v1v2 v2 v2v2’ v2’ v2’v3’ v2” v2”v1’ v1’ v2v3 v2’ v2’v3’ v3’ v3’v1 v1’v2 v2 v3v1 v3’v1 v3’v1 v1 v1v2 v1’v2 v2v2’ v2’ v1v2 v2 v2v2’ v2’ v2’v2” v2” Edges Output Edges Output Edges Output Edges Output Final
8. 8. •Weiler- Atherton Polygon ClippingIn this algorithm,the vertex –processing procedures for windowboundaries are modified so that concave polygons are displayedcorrectly. This clipping procedure was developed as a method foridentifying visible surfaces,and so it can be applied with arbitrarypolygon-clipping regions.The basic idea in this algorithm is that instead of alwaysproceeding around the polygon edges as vertices areprocessed,we sometimes want to follow the windowboundaries .Which path we follow depend on the polygon-processing direction(clockwise or counterclockwise)
9. 9. Sutherland-HodgmanWeiler-Atherton
10. 10. •Importance of clipping in video gamesGood clipping strategy is important in the development of videogames in order to maximize the games frame rate and visualquality. Despite GPU chips that are faster every year, it remainscomputationally expensive to transform, texture, and shadepolygons, especially with the multiple texture and shading passescommon today To maximize the games visual quality,developers prefer to establish the highest possible polygonbudget; therefore, every optimization of the graphics pipelinebenefits the polygon budget and therefore the game.In video games, then, clipping is a critically importantoptimization that speeds up the rendering of the current scene,and therefore allows the developer to increase the rendererspolygon budget.