Title: Determine whether a polygon is oriented clockwise or counterclockwise in C#
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.
|