Plotting irregular volume of given vertices.

I am using convhull for plotting 3D irregular volume for a given set of vertices(more than 10). But the resulting volume consist of lines connecting between all vertices as shown in the figure.
Is there any method to plot only the faces and avoid the lines passing through the volume?
if true
% code
x=pts1(:,1);y=pts1(:,2);z=pts1(:,3);
k = convhull(x,y,z);
plot3(x(k),y(k),z(k),'r-')
end
Thanks Shyam

 채택된 답변

David Goodmanson
David Goodmanson 2018년 5월 7일
편집: David Goodmanson 2018년 5월 7일

0 개 추천

Hi syham,
Here is an example using patch.
n = 6;
x = rand(1,n);
y = rand(1,n);
z = rand(1,n);
k = convhull(x,y,z)';
colorr = [.7 .2 .3];
close % temporary expedient for situation mentioned below
figure(1)
patch(x(k),y(k),z(k),colorr);
alpha(.2) % transparancy
Unlike e.g. the plot command, the patch command seems to put the figure into a permanent 'hold on' state so that another patch command adds to what is already there. Not a big deal, but I don't know how to plot a new convex hull without closing the figure first or adding another figure.

댓글 수: 1

John D'Errico
John D'Errico 2018년 5월 8일
편집: John D'Errico 2018년 5월 8일
Trimesh is a simple alternative. It shouldn't leave the graphic on hold either.
xyz = randn(100,3);
tri = convhulln(xyz);
trimesh(tri,xyz(:,1),xyz(:,2),xyz(:,3),'facecolor','r','facealpha',.3,'edgecolor','k')

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by