Hi,
I'm trying to make some 3D plots in matlab where the hidden lines
are drawn dotted, whereas the visible lines are drawn solid.
For example for the unit cube, I would like the following figure:
figure(1); clf; hold on;
ED={[1 2], [1 3], [1 5]};
ES={[6 8],[2 4], [2 6], [4 8], [5 7], [5 6], [8 7], [7 3],[4 3]};
for i=1:length(ED)
L=ED{i}; X=P(L,1); Y=P(L,2); Z=P(L,3);
plot3(X,Y,Z,'b--');
end
for i=1:length(ES)
L=ES{i}; X=P(L,1); Y=P(L,2); Z=P(L,3);
plot3(X,Y,Z,'b-');
end
view(118,16);
xlabel('x'); ylabel('y'); zlabel('z');
The point is that I don't want to this manually. That is, I want matlab
to determine which lines are hidden. A partial solution is
to use the patch function, e.g.
P=[0 0 0; 1 0 0; 0 1 0; 1 1 0; 0 0 1; 1 0 1; 0 1 1; 1 1 1];
F=[1 3 7 5; 2 4 8 6; 1 2 6 5; 3 4 8 7; 1 2 4 3; 5 6 8 7];
figure(1); clf; hold on;
h=patch('Vertices',P,'Faces',F,'FaceColor','w','LineStyle','-',...
'LineWidth',1,'EdgeColor','b');
view(118,16);
xlabel('x'); ylabel('y'); zlabel('z');
but now the hidden lines are invisible..
Anyone who knows how to solve this?
Thanks,
Haakon Hagland
|