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.

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

2-D polygons

The `polyshape`

function creates a polygon defined by 2-D
vertices, and returns a `polyshape`

object with properties describing
its vertices, solid regions, and holes. For example, ```
pgon = polyshape([0 0 1
1],[1 0 0 1])
```

creates the solid square defined by the four points (0,1),
(0,0), (1,0), and (1,1).

>> pgon = polyshape([0 0 1 1],[1 0 0 1])

pgon = polyshape with properties: Vertices: [4×2 double] NumRegions: 1 NumHoles: 0

>> plot(pgon)

When creating a `polyshape`

object, the input vertices should define
one or more boundaries of a polygon that have no intersections and are properly nested.
Otherwise, the `polyshape`

function automatically alters the input
vertices as needed to create a well-defined polygon.

`pgon = polyshape()`

`pgon = polyshape(x,y)`

`pgon = polyshape(P)`

`pgon = polyshape(X,Y)`

`pgon = polyshape(___,Name,Value)`

`pgon = polyshape()`

creates an empty
`polyshape`

object.

`pgon = polyshape(`

creates a
`P`

)`polyshape`

from the 2-D vertices defined in the
*N*-by-2 matrix `P`

, where
*N* is the number of vertices. The first column of
`P`

defines the *x*-coordinates, and the
second column defines the `y`

-coordinates.

`pgon = polyshape(___,`

specifies additional parameters for creating a `Name,Value`

)`polyshape`

object for any of the previous syntaxes.

Was this topic helpful?