This example contains a `Polygon` class that perform several useful geometric operations for polygons. The following list describes the key methods provided by the class. Click the links to see posts that describe the methods in greater detail.

- PolygonIsConvex – Returns
`true`if the polygon is convex - PointInPolygon – Returns
`true`if a point in inside the polygon - PolygonArea – Returns the polygon’s area
- FindCentroid – Returns the polygon’s centroid (“center of mass”)
- PolygonIsOrientedClockwise – Returns
`true`if the polygon’s points are oriented clockwise - OrientPolygonClockwise – Orients the polygon’s points clockwise
- Triangulate – Chops the polygon into triangles
- FindSmallestBoundingRectangle – Returns a smallest rectangle that surrounds the polygon (not necessarily parallel to the X and Y axes)

To use the example, click to add points to the polygon. Then use function keys or the menu to perform the operations.

The “Point in Polygon” test is a bit odd because it uses the mouse’s current position as the point you want to test. If you use the menu item to perform the test, the point is wherever the menu item is. To test points without using the menu, press F3.

Note also that the Bounding Rectangle operation only works for convex polygons.

Find a smallest enclosing rectangle for a polygon in C#This program assumes that the polygon is convex and oriented counter-clockwise. This example demonstrates the Rotating Calipers method for finding a minimal bounding rectangle around the polygon. The algorithm is a bit tricky to visualize so you may want to run the program a few times while you read the following description. Each time you click the Step button, the program performs one iteration of the algorithm and examines one candidate bounding rectangle. First note that any minimal bounding rectangle has at least one edge that coincides with one of the polygon’s edges. The three other sides of …