www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/EnclosingTrianglesOfQueryPointsExample.m
%% Find Enclosing Triangles of Query Points % %% % Define the points and connectivity of the triangulation. % Copyright 2015 The MathWorks, Inc. P = [2.5 8.0; 6.5 8.0; 2.5 5.0; 6.5 5.0; 1.0 6.5; 8.0 6.5]; T = [5 3 1; 3 2 1; 3 4 2; 4 6 2]; TR = triangulation(T,P); %% % Define two query points. QP = [2.25 7; 6 6.5]; %% % Plot the triangulation and the query points. triplot(TR) hold on plot(QP(:,1),QP(:,2),'r*') ylim([4 9]) xlim([0 9]) %% % Determine which triangles in the triangulation enclose each query point. ti = pointLocation(TR,QP) %% % Highlight the triangles that enclose each of the query points. triplot(TR.ConnectivityList(ti,:),P(:,1),P(:,2),'c')