一、凸多边形
x = rand(10,1)
y = rand(10,1)
dt = delaunayTriangulation(x,y)
[k a] = convexHull(dt)
plot(dt.Points(:,1),dt.Points(:,2), ‘.’, ‘markersize’,10); hold on;
plot(dt.Points(k,1),dt.Points(k,2), ‘r’); hold off;
得到
k = 4
10
7
9
4
a =
0.4075
二、凸多面体
X = rand(25,3);
dt = delaunayTriangulation(X);
[ch v] = convexHull(dt);
trisurf(ch, dt.Points(:,1),dt.Points(:,2),dt.Points(:,3), ‘FaceColor’, ‘cyan’)
>> %体积
v =
0.4133
转载本文请联系原作者获取授权,同时请注明本文来自王福昌科学网博客。
链接地址:http://blog.sciencenet.cn/blog-292361-1055925.html
上一篇:MATLAB中绘制数据直方图的新函数histogram2
下一篇:Cleve Moler 的两本MATLAB教材