Reverse the orientation of a polygon in C#

Reverse polygon orientation

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 Example   Follow me on Twitter   RSS feed




This entry was posted in algorithms, geometry, graphics, mathematics and tagged , , , , , , , , , , , , . Bookmark the permalink.

2 Responses to Reverse the orientation of a polygon in C#

  1. Pingback: Find a minimal bounding rectangle for a polygon in C# |

  2. Pingback: Perform geometric operations on polygons in C# |

Leave a Reply

Your email address will not be published. Required fields are marked *