%% Vertex Mapping
% Create two polygons and compute their intersection. Display the vertex coordinates of the intersection and the corresponding vertex mapping information.

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]);
[polyout,shapeID,vertexID] = intersect(poly1,poly2);

[polyout.Vertices shapeID vertexID]

% The first two vertices of the intersection originated in poly2, since the corresponding values in shapeID are 2.These vertices are the first and second vertices in the property poly2.Vertices, respectively, since their corresponding values in vertexID are 1 and 2. The last two vertices of polyout were created from the intersection because the corresponding values in shapeID and vertexID are 0.
% Copyright 2012 The MathWorks, Inc.