[C# Helper]
Index Books FAQ Contact About Rod
[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]

[Beginning Software Engineering]

[C# 5.0 Programmer's Reference]

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

Title: Determine whether a polygon is oriented clockwise or counterclockwise in C#

Polygon orientation

The post Calculate the area of a polygon in C# explains how to calculate the "signed area" of a polygon. That Polygon class's SignedPolygonArea method returns a positive area if the polygon is oriented clockwise and a negative area if it is oriented counterclockwise.

The following PolygonIsOrientedClockwise method uses SignedPolygonArea method to determine whether a polygon is oriented clockwise.

// Return true if the polygon is oriented clockwise. public bool PolygonIsOrientedClockwise() { return (SignedPolygonArea() < 0); }

See the previous post for information about how the SignedPolygonArea method works.

Download the example to experiment with it and to see additional details.

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