[C# Helper]
Index Books FAQ Contact About Rod
[Beginning Database Design Solutions, Second Edition]

[Beginning Software Engineering, Second Edition]

[Essential Algorithms, Second Edition]

[The Modern C# Challenge]

[WPF 3d, Three-Dimensional Graphics with WPF and C#]

[The C# Helper Top 100]

[Interview Puzzles Dissected]

[C# 24-Hour Trainer]

[C# 5.0 Programmer's Reference]

[MCSD Certification Toolkit (Exam 70-483): Programming in C#]

Title: 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 the example to experiment with it and to see additional details.

© 2009-2023 Rocky Mountain Computer Consulting, Inc. All rights reserved.