poly2cw

Convert polygon contour to clockwise vertex ordering

Syntax

(x2, y2) = poly2cw (x1, y1)

Description

(x2, y2) = poly2cw (x1, y1)arranges the Cartesian vertices in the polygonal contour (x1,y1) in clockwise order, returning the result inx2andy2. Ifx1andy1can contain multiple contours, represented either asNaN-separated vectors or as cell arrays, then each contour is converted to clockwise ordering.x2andy2have the same format (NaN-separated vectors or cell arrays) asx1andy1.

Examples

Convert a counterclockwise-ordered square to clockwise ordering.

x1 = [0 1 1 0 0];日元=[0 0 1 1 0]; ispolycw(x1, y1) ans = 0 [x2, y2] = poly2cw(x1, y1); ispolycw(x2, y2) ans = 1

Tips

You can usepoly2cwfor geographic coordinates if the polygon does not cross the Antimeridian or contain a pole. A polygon contains a pole if the longitude data spans 360 degrees. To usepoly2cwwith geographic coordinates, specify the longitude vector asx1and the latitude vector asy1.

Introduced before R2006a