%% Intersection of Two Polygons
% Create and plot two polygons.

poly1 = polyshape([0 0 1 1],[1 0 0 1]);
poly2 = polyshape([0.75 1.25 1.25 0.75],[0.25 0.25 0.75 0.75]);
plot(poly1)
hold on
plot(poly2)
figure

%
% Compute and plot the intersection of poly1 and poly2.

polyout = intersect(poly1,poly2)
plot(polyout)
xlim([-0.2 1.4]);
ylim([-0.2 1.2]);

% Copyright 2012 The MathWorks, Inc.