www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/ThreeDDelaunayTriangulationExample.m

    %% 3-D Delaunay Triangulation
% This example generates an n-dimensional Delaunay triangulation, where |n = 3|. 

% Copyright 2015 The MathWorks, Inc.

d = [-1 1];
[x,y,z] = meshgrid(d,d,d);  % A cube
x = [x(:);0];
y = [y(:);0];
z = [z(:);0];
% [x,y,z] are corners of a cube plus the center.
X = [x(:) y(:) z(:)];
Tes = delaunayn(X)

%%
% You can use |tetramesh| to visualize the tetrahedrons that form 
% the corresponding simplex. |camorbit| rotates the camera position
% to provide a meaningful view of the figure.
tetramesh(Tes,X);
camorbit(20,0)