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. Please click here
To view all translated materials including this page, select Japan from the country navigator on the bottom of this page.


Convert polygon contour to counterclockwise vertex ordering


[x2, y2] = poly2ccw(x1, y1)


[x2, y2] = poly2ccw(x1, y1) arranges the vertices in the polygonal contour (x1, y1) in counterclockwise order, returning the result in x2 and y2. If x1 and y1 can contain multiple contours, represented either as NaN-separated vectors or as cell arrays, then each contour is converted to clockwise ordering. x2 and y2 have the same format (NaN-separated vectors or cell arrays) as x1 and y1.


Convert a clockwise-ordered square to counterclockwise ordering.

x1 = [0 0 1 1 0];
y1 = [0 1 1 0 0];
ispolycw(x1, y1)

ans =

[x2, y2] = poly2ccw(x1, y1);
ispolycw(x2, y2)
ans =

Introduced before R2006a

Was this topic helpful?