Polygon Clipping: A polygon is a closed sided figure represented by a number of line segments that are connected to each other end to end. The various line segments are called edges or sides and the points where two edges meet are called vertices or corners. A simplest polygon which exists in the Euclidean plane is triangle with three sides and three vertices.
On the basis of their convexity polygons are of two types:
- Convex polygon
- Concave polygon
1. Convex polygon
A convex polygon is a polygon where every internal angle is less than or equal to 180°. In this polygon, any line drawn through the polygon (and not tangent to an edge or corner) meets its boundary exactly twice. Also, all the diagonals of convex polygon lie entirely inside the polygons. We can also say that a polygon is convex if the line joining any two interior points of the polygon lies completely inside the polygon.
2. Concave polygon
A concave polygon is one which has one or more interior angle greater than 180. In this polygon, a line drawn through a polygon can intersect polygon at more than two places. Also, some of the diagonals will lie outside the polygon. Thus, we can also say that a polygon is concave if the line joining any two interior points of the polygon; does not lie completely inside the polygon.
Algorithms for Polygon Clipping:
There are two main algorithms for Polygon Clipping: