poly2cw
Convert polygon vertices to clockwise order
Syntax
Description
Examples
Convert Vertices to Clockwise Order
Specify a polygon using vertices in counterclockwise order. Close the polygon by repeating the first vertex at the end of the list.
x1 = [0 3 4 1 0]; y1 = [0 2 3 1 0]; ispolycw(x1,y1)
ans = logical
0
Arrange the vertices so they are in clockwise order.
[x2,y2] = poly2cw(x1,y1); ispolycw(x2,y2)
ans = logical
1
Input Arguments
x1
— x-coordinates of polygon
numeric vector | cell array of numeric vectors
x-coordinates of the polygon, specified as a numeric vector or a cell array of numeric vectors.
Define one polygon by specifying a vector, such as
[39 45 19 39]
.Define multiple polygons by using one of these options:
Specify a vector and separate the polygons using
NaN
values, such as[37 46 31 20 37 NaN 45 49 35 32 45 NaN 35 40 42 35]
. TheNaN
values inx1
must correspond to theNaN
values iny1
.Specify a cell array of vectors, such as
{[37 46 31 20 37],[45 49 35 32 45],[35 40 42 35]}
. The size of the vector in each cell ofx1
must match the size of the vector in the corresponding cell ofy1
.
The size and type of x1
must match the size and type of
y1
.
y1
— y-coordinates of polygon
numeric vector | cell array of numeric vectors
y-coordinates of the polygon, specified as a numeric vector or a cell array of numeric vectors.
Define one polygon by specifying a vector, such as
[-113 -49 -100 -113]
.Define multiple polygons by using one of these options:
Specify a vector and separate the polygons using
NaN
values, such as[69 90 105 79 69 NaN 6 52 43 14 6 NaN 18 32 22 18]
. TheNaN
values iny1
must correspond to theNaN
values inx1
.Specify a cell array of vectors, such as
{[69 90 105 79 69],[6 52 43 14 6],[18 32 22 18]}
. The size of the vector in each cell ofy1
must match the size of the vector in the corresponding cell ofx1
.
The size and type of y1
must match the size and type of
x1
.
Output Arguments
x2
— x-coordinates in clockwise order
numeric vector | cell array of numeric vectors
x-coordinates in clockwise order, returned as a numeric vector or a cell array of numeric vectors.
When x1
and y1
define multiple polygons,
the poly2cw
function converts the coordinates of each individual
polygon to clockwise order.
The size and type of x2
matches the size and type of
x1
.
Data Types: double
y2
— y-coordinates in clockwise order
numeric vector | cell array of numeric vectors
y-coordinates in clockwise order, returned as a numeric vector or a cell array of numeric vectors.
When x1
and y1
define multiple polygons,
the poly2cw
function converts the coordinates of each individual
polygon to clockwise order.
The size and type of y2
matches the size and type of
y1
.
Data Types: double
Tips
You can specify geographic coordinates as input to the poly2cw
function when the polygon does not cross the Antimeridian or contain a pole. A polygon
contains a pole when the longitude data spans 360 degrees. To use geographic coordinates as
input, specify x1
using the longitude vector and y1
using the latitude vector.
Version History
Introduced before R2006a
See Also
Functions
Objects
Abrir ejemplo
Tiene una versión modificada de este ejemplo. ¿Desea abrir este ejemplo con sus modificaciones?
Comando de MATLAB
Ha hecho clic en un enlace que corresponde a este comando de MATLAB:
Ejecute el comando introduciéndolo en la ventana de comandos de MATLAB. Los navegadores web no admiten comandos de MATLAB.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)