Note: This page has been translated by MathWorks. Please click here

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

To view all translated materals including this page, select Japan 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()`

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(`

creates a polygon consisting of `{x1,x2,...,xM}`

},`{y1,y2,...,yM}`

)*M* boundaries, where the
vectors of *x*-coordinates for each boundary are listed
together in a cell array, and the corresponding vectors of
*y*-coordinates are also listed together in a cell array. Each
*x _{i}* must have the same length
as the corresponding

`pgon = polyshape(___,`

specifies additional parameters for creating a `Name,Value`

)`polyshape`

object for any of the previous syntaxes.

Modify

`addboundary` | Add polyshape boundary |

`rmboundary` | Remove polyshape boundary |

`rmholes` | Remove holes in polyshape |

`rmslivers` | Remove polyshape boundary outliers |

`simplify` | Simplify polyshape boundaries |

Query

`boundary` | Vertex coordinates of polyshape boundary |

`isequal` | Determine if polyshape objects are equal |

`ishole` | Determine if polyshape boundary is a hole |

`isinterior` | Query points inside polyshape |

`issimplified` | Determine if polyshape is well-defined |

`numboundaries` | Number of polyshape boundaries |

`numsides` | Number of polyshape sides |

Geometric Quantities

`area` | Area of polyshape |

`boundingbox` | Bounding box of polyshape |

`centroid` | Centroid of polyshape |

`convhull` | Convex hull of polyshape |

`perimeter` | Perimeter of polyshape |

`triangulation` | Triangulate polyshape |

Boolean Operations

Transformation

`polybuffer` | Buffer polyshape |

`rotate` | Rotate polyshape |

`scale` | Scale polyshape |

`translate` | Translate polyshape |

Utility

`holes` | Convert polyshape hole boundaries to array of polyshape objects |

`plot` | Plot polyshape |

`regions` | Perimeter of polyshape |

`sortboundaries` | Sort polyshape boundaries |

`sortregions` | Sort polyshape regions |

Was this topic helpful?