Reverse a polygon's orientation in C#

Reversing a polygon's orientation is easy. Simply reverse the order of its points. If the points are stored in an array of Point or PointF, you can call the Array.Reverse method.

The OrientPolygonClockwise function 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 on polygon orientation, see Determine whether a polygon's points are oriented clockwise in C#.

   

 

What did you think of this article?




Trackbacks
  • No trackbacks exist for this post.
Comments
  • No comments exist for this post.
Leave a comment

Submitted comments are subject to moderation before being displayed.

 Name

 Email (will not be published)

 Website

Your comment is 0 characters limited to 3000 characters.