Polygon ClippingCollection of connected lines is considered asPolygon. A polygon clipper takes as input thevertices of a polygon and returns one(or more)polygons. A closed Polygon when clipped Cthen we may get one or more open c d polygon or Dlines. a A b B
When we want clipping of a solid polygonarea(closed polygon), then after clipping theresulting polygon should be closed. It requiresthat lines ab & cd be added to make it closedpolygon. Hence it is difficult to find out whichpieces of sections should be joined to makethe clipped polygon closed.
A polygon is called convex if the line joining any two interior points of the polygon lies completely inside the polygon. A non- convex polygon is said to be concave. B B A A
Another problem occurs when clipping aclosed polygon into several distinct smallerpolygons as shown: Clipping Window Concave Polygon
By convention, a polygon with vertices p1..pnis said to be positively oriented if it producesa anticlockwise direction. And if producesclockwise it will be negative oriented. C D D C L R E L R E B B A A
SUTHERLAND-HODGMAN ALGORITHM Each edge of the polygon must be testedagainst each edge of the clip rectangle; newedges must be added, and existing edges mustbe discarded, retained, or divided. Multiplepolygons may result from clipping a singlepolygon. We need an organized way to dealwith all these cases.
Steps of Sutherland-Hodgmans polygonclipping algorithm Polygons can be clipped against each edge of the window one at a time.
Vertices which are kept after clipping against one window edge are saved for clipping against the remaining edges. Note that the number of vertices usually changes and will often increases. The original polygon and the clip rectangle.
After clipped by theright clip boundary.After clipped by the right and bottomclip boundaries.
After clipped by theright, bottom, andleft clip boundaries.After clipped byall fourboundaries.
Four Cases of polygon clipping against oneEdge:The clip boundary determines a visible andInvisible region. The edges from vertex can beone of four types: Case 1 : Wholly inside visible region - save endpoint Case 2 : Exit visible region - save the intersection
Case 3 : Wholly outside visible region - save nothing Case 4 : Enter visible region - save intersection and endpoint V1 V2 V1 V1’ V2 Out in in in Save V1’,V2 Save V2
V2 V1V2 V1’ V1 in out out out Save V1’ Save none