: q = orientPolygon (p)
: … = orientPolygon (p, [], dir)
: [qx qy] = orientPolygon (px, py)
: … = orientPolygon (px, py, dir)

Orient polygon counterclockwise or clockwise.

p is a N-by-2 array containing coordinates of vertices. The coordinates of the vertices of the polygon can also be given as two N-by-1 arrways px, py. It can also be cells of polygons or NaN separated polygons. The output has the same format as the input.

The optional argument dir can be "ccw" or "cw". By default it orients polygon counterclockwise (dir == "ccw"). To orient the polygon clockwise, use dir == "cw".

Holes are treated as independet polygons, that is a cw polygon with a cw hole will be seen as two cw polygons.

If polygon is self-crossing, the result is undefined.

See also: isPolygonCCW.

Package: geometry