## Quickly determining if a closed polyline is clockwise or counter-clockwise

Moderator
Posts: 1,554
Joined: 2003.10
Post: #5
(Apr 9, 2011 01:24 PM)Skorche Wrote:  You do need a point inside the polygon to start though. An easy way to handle that would be to pick a segment on the perimeter. Have the point be the midpoint of the segment, and the ray direction be it's negative normal.

How will you know the normal if you don't know the winding order, though? I suppose you could check in both possible normal directions, and determine winding based on which one gets an intersection with another segment.

You say there's no guarantee of convexity/concavity; hopefully there's at least a guarantee that it's not self-intersecting? If not, you're hosed, since it'd have both clockwise and counterclockwise portions in that case.

 Messages In This Thread Quickly determining if a closed polyline is clockwise or counter-clockwise - TomorrowPlusX - Apr 9, 2011, 11:56 AM RE: Quickly determining if a closed polyline is clockwise or counter-clockwise - stevejohnson - Apr 9, 2011, 12:32 PM RE: Quickly determining if a closed polyline is clockwise or counter-clockwise - TomorrowPlusX - Apr 9, 2011, 12:44 PM RE: Quickly determining if a closed polyline is clockwise or counter-clockwise - Skorche - Apr 9, 2011, 01:24 PM RE: Quickly determining if a closed polyline is clockwise or counter-clockwise - ThemsAllTook - Apr 9, 2011 01:40 PM RE: Quickly determining if a closed polyline is clockwise or counter-clockwise - TomorrowPlusX - Apr 9, 2011, 01:53 PM RE: Quickly determining if a closed polyline is clockwise or counter-clockwise - Skorche - Apr 9, 2011, 04:03 PM