示例一:建立并绘制2D Delaunay三角剖分
本示例申明若何计较2D Delaunay三角剖分以及若何将三角剖分与极点和三角形标签一路绘制。
在号令行窗口,输入号令:
x = rand(10,1);
y = rand(10,1);
dt = delaunayTriangulation(x,y)
按“Enter键”。
如图1所示。
在号令行窗口,输入号令:
triplot(dt);
%
% Display the Vertex and Triangle labels on the plot
hold on
vxlabels = 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所示。
示例二:建立并绘制3D Delaunay三角剖分
本示例标的目的您展示若何计较3D Delaunay三角剖分以及若何绘制三角剖分。
在号令行窗口,输入号令:
X = rand(10,3)
按“Enter键”。
如图3所示。
在号令行窗口,输入号令:
dt = delaunayTriangulation(X)
按“Enter键”。
如图4所示。
在号令行窗口,输入号令:
tetramesh(dt, 'FaceColor', '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所示。
示例三:拜候三角剖分数据布局
有两种方式可以拜候三角测量数据布局。 一种方式是经由过程Triangulation属性,另一种方式是利用索引。
从10个随机点建立2D Delaunay三角剖分。
在号令行窗口,输入号令:
X = rand(10,2)
按“Enter键”。
如图6所示。
在号令行窗口,输入号令:
dt = delaunayTriangulation(X)
按“Enter键”。
如图7所示。
在号令行窗口,输入号令:
% The triangulation datastructure is;
dt.ConnectivityList
按“Enter键”。
如图8所示。
在号令行窗口,输入号令:
% 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 is
dt(:,:)
按“Enter键”。
如图9所示。
第二个三角形是;
在号令行窗口,输入号令:
dt(2,:)
按“Enter键”。
如图10所示。
第二个三角形的第三个极点是;
在号令行窗口,输入号令:
dt(2,3)
按“Enter键”。
如图11所示。
前三个三角形;
在号令行窗口,输入号令:
dt(1:3,:)
按“Enter键”。
如图12所示。
0 篇文章
如果觉得我的文章对您有用,请随意打赏。你的支持将鼓励我继续创作!