True if polygon vertices are in clockwise order
tf = ispolycw(x, y)
Alternatively, x and y can contain multiple contours, either in NaN-separated vector form or in cell array form. In that case, ispolycw returns a logical array containing one true or false value per contour.
ispolycw always returns true for polygonal contours containing two or fewer vertices.
Vertex ordering is not well defined for self-intersecting polygonal contours. For such contours, ispolycw returns a result based on the order or vertices immediately before and after the left-most of the lowest vertices. In other words, of the vertices with the lowest y value, find the vertex with the lowest x value. For a few special cases of self-intersecting contours, the vertex ordering cannot be determined using only the left-most of the lowest vertices; for these cases, ispolycw uses a signed area test to determine the ordering.
Orientation of a square:
x = [0 1 1 0 0]; y = [0 0 1 1 0]; ispolycw(x, y) % Returns 0 ispolycw(fliplr(x), fliplr(y)) % Returns 1