COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### How to draw hidden lines dotted?

• Follow

```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
```
 0

```Dear Haakon,

> but now the hidden lines are invisible..

The definition of "hidden" includes the invisibility.
An automatical detection of the hidden lines is not trivial. Imagine that a line can he hidden just partially!
What about using semi-transparent patch objects? Then the hidden lines are not dotted, but shaded.

Kind regards, Jan
```
 0

```On 29/10/10 12:57, Jan Simon wrote:
> Dear Haakon,
>
>> but now the hidden lines are invisible..
>
> The definition of "hidden" includes the invisibility.
> An automatical detection of the hidden lines is not trivial. Imagine
> that a line can he hidden just partially!
> What about using semi-transparent patch objects? Then the hidden lines
> are not dotted, but shaded.
>
> Kind regards, Jan

Thanks,

Of course, you are right.
I can see the problem with partially hidden lines. But it would be very
nice to this functionality in matlab.

Yes, I can use semi-transparant objects (if I have to :))

Best regards,
Haakon
```
 0

2 Replies
585 Views

Similiar Articles:

7/22/2012 9:36:08 PM