www.gusucode.com > map 案例源码 matlab代码程序 > map/CalculateIntersectionsOfArbitraryVectorDataExample.m
%% Calculate Intersections of Arbitrary Vector Data % This example shows how to calculate the intersections of arbitrary vector % data, such as polylines or polygons, using the |polyxpoly| function. %% % Create two polygons that intersect. % Copyright 2015 The MathWorks, Inc. x1 = [10 20 40 50 50 40 20 10 10]; y1 = [20 10 10 20 40 50 50 40 20]; x2 = [30 60 30 0 30]; y2 = [40 50 70 60 40]; %% % Plot the polygons. mapshow(x1,y1) mapshow(x2,y2) %% % Calculate the points where these two polygons intersect. The |polyxpoly| % command finds the segments that intersect and interpolates to find the % intersection points. [xint,yint] = polyxpoly(x1,y1,x2,y2) %% % Display the points of intersection. If the spacing between points is % large, there can be some difference between the intersection points % computed by |polyxpoly| and the intersections shown on a map display. % This is a result of the difference between straight lines in the % unprojected and projected coordinates. Similarly, there can be % differences between the |polyxpoly| result and intersections assuming % great circles or rhumb lines between points. mapshow(xint,yint,'Displaytype','point','Marker','o')