addboundary
Adds a new polygonal boundary to a polyshape and returns the combined shape.
Category: Mathematics > Computational Geometry
Syntax
pshape = addboundary(pshape, x, y)
Adds the polygon with vertices (x, y) as a new boundary of pshape.
Description
addboundary is the way to put a second polygon, such as a separate island, into an existing polyshape without taking a union. The result is normalized: a new boundary lying inside an existing one becomes a hole, while a separate one becomes another region.
The original object is not changed; the function returns a new polyshape.
Input arguments
pshape- A
polyshapeobject. x, y- Vectors with the x and y coordinates of the new boundary's vertices, in order around the polygon.
Output arguments
pshape- A
polyshapewith the original boundaries plus the new one.
Example
Two separate squares
P = polyshape([0 4 4 0], [0 0 3 3]);
B = addboundary(P, [5 6 6 5], [0 0 1 1]);
disp(B.NumRegions)
disp(area(B))
Output
2
13