%% Intersecting Boundary
% Create and plot a polygon that contains a boundary intersection.

P = [0 0; 1 1; 1 0; 0.5 0.5; 0 1; 0 0];
polyin = polyshape(P,'Simplify',false)
plot(polyin)

%
% Use the simplify function to remove the intersection, which produces a well-defined polygon. Simplifying the polygon maintains the boundary shape, but splits the polygon into two distinct regions.

polyout = simplify(polyin)

% Copyright 2012 The MathWorks, Inc.