This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.


True if polygon vertices are in clockwise order


tf = ispolycw(x, y)


tf = ispolycw(x, y) returns true if the polygonal contour vertices represented by x and y are ordered in the clockwise direction. x and y are numeric vectors with the same number of elements.

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.

Class Support

x and y may be any numeric class.


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

Introduced before R2006a

Was this topic helpful?