Title: Reverse the orientation of a polygon in C#
Reversing the orientation of a polygon is easy. Simply reverse the order of its points. If the points are stored in an array of Point or PointF, you can just call the Array.Reverse method.
The Polygon class's OrientPolygonClockwise method shown in the following code checks a polygon's orientation and reverses it if it is not already oriented clockwise.
// If the polygon is oriented counterclockwise,
// reverse the order of its points.
private void OrientPolygonClockwise()
{
if (!PolygonIsOrientedClockwise())
Array.Reverse(Points);
}
For more information on polygon orientation, see Determine whether a polygon is oriented clockwise or counterclockwise in C#.
Download the example to experiment with it and to see additional details.
|