1、示例一:创建并绘制2D Delaunay三角剖分本示例说明如何计算2D Delaunay三角剖分以及如何将三角剖分与顶点和三角形标签一起绘制。在命令行窗口,输入命令:x = rand(10,1);y = rand(10,1);dt = delaunayTriangulation(x,y)按“Enter键”。如图1所示。
2、在命令行窗口,输入命令:triplot(dt);%% Display the Ve筠续师诈rtex and Triangle labels o荏鱿胫协n the plothold onvxlabels = arrayfun(@(n) {sprintf('P%d', n)}, (1:10)');Hpl = text(x, y, vxlabels, 'FontWeight', 'bold', 'HorizontalAlignment',... 'center', 'BackgroundColor', 'none');ic = incenter(dt);numtri = size(dt,1);trilabels = arrayfun(@(x) {sprintf('T%d', x)}, (1:numtri)');Htl = text(ic(:,1), ic(:,2), trilabels, 'FontWeight', 'bold', ... 'HorizontalAlignment', 'center', 'Color', 'blue');hold off按“Enter键”。如图2所示。
3、示例二:创建并绘制3D Delaunay三角剖分本示例向您展示如何计算3D Delaunay三角剖分以及如何绘制三角剖分。在命令行窗口,输入命令:X = rand(10,3)按“Enter键”。如图3所示。
4、在命令行窗口,输入命令:dt = delaunayTriangulation(X)按“Enter键”。如图4所示。
5、在命令行窗口,输入命令:tetramesh(dt, 'FaceColor&拭貉强跳#39;, 'cyan');% To display large tetrahedral meshes use the convexHull method to% compute the boundary triangulation and plot it using trisurf.% For example;% triboundary = convexHull(dt)% trisurf(triboundary, X(:,1), X(:,2), X(:,3), 'FaceColor', 'cyan')按“Enter键”。如图5所示。
6、示例三:访问三角剖分数据结构有两种方法可以访问三角测量数据结构。 一种方法是通过Triangulation属性,另一种方法是使用索引。从10个随机点创建2D Delaunay三角剖分。在命令行窗口,输入命令:X = rand(10,2)按“Enter键”。如图6所示。
7、在命令行窗口,输入命令:dt = delaunayTriangulation(X)按“Enter键”。如图7所示。
8、在命令行窗口,输入命令:% The triangulation datastructure is;dt.ConnectivityList按“Enter键”。如图8所示。
9、在命令行窗口,输入命令:% Indexing is a shorthand way to query the triangulation. The format 足毂忍珩is% dt(i, j) where j is the j'th vertex of the i'th triangle, standard% indexing rules apply.% The triangulation datastructure isdt(:,:)按“Enter键”。如图9所示。
10、第二个三角形是;在命令行窗口,输入命令:dt(2,:)按“Enter键”。如图10所示。
11、第二个三角形的第三个顶点是;在命令行窗口,输入命令:dt(2,3)按“Enter键”。如图11所示。
12、前三个三角形;在命令行窗口,输入命令:dt(1:3,:)按“Enter键”。如图12所示。