www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/MappedIncentersofDeformedTriangulationExample.m
%% Mapped Incenters of Deformed Triangulation % Copyright 2015 The MathWorks, Inc. %% % Create a Delaunay triangulation from a set of points. x = [0 4 8 12 0 4 8 12]'; y = [0 0 0 0 8 8 8 8]'; DT = delaunayTriangulation(x,y); %% % Calculate the Cartesian coordinates of the incenters. cc = incenter(DT); %% % Plot the original triangulation and reference points. figure subplot(1,2,1); triplot(DT); hold on; plot(cc(:,1),cc(:,2),'*r'); hold off; axis equal; %% % Create a new triangulation which is a deformed version of |DT| . ti = DT.ConnectivityList; y = [0 0 0 0 16 16 16 16]'; TR = triangulation(ti,x,y); %% % Compute the barycentric coordinates for the incenters of |DT|, and use % them to compute the Cartesian coordinates of the analogous points in |TR|. b = cartesianToBarycentric(DT,[1:length(ti)]',cc); xc = barycentricToCartesian(TR,[1:length(ti)]',b); %% % Plot the deformed triangulation and mapped locations of the reference points. subplot(1,2,2); triplot(TR); hold on; plot(xc(:,1),xc(:,2),'*r'); hold off; axis equal;