Patch: Problem using FaceVertexAlphaData to control edge visibility

Hello Community,
I encountered an unexpected behaviour using the patch function. Creating a simple four-sided pyramid and using FaceVertexAlphaData property to control edge visibility one edge is not highlighted.
vertices = [0.0,0.0,0.0;
1.0,0.0,0.0;
1.0,1.0,0.0;
0.0,1.0,0.0;
0.5,0.5,0.5];
fvad = [1,1,1,1,0]';
faces = [1,2,5;
2,3,5;
3,4,5;
4,1,5];
figure
patch('Faces',faces,...
'Vertices',vertices,...
'FaceVertexAlphaData',fvad,...
'EdgeAlpha','flat',...
'LineWidth',1.5,...
'FaceColor','red',...
'EdgeColor','blue');
view(3);
camlight
When calling the patch function face-wise all edges will be displayed.
figure
for i=1:size(faces,1)
patch('Faces',faces(i,:),...
'Vertices',vertices,...
'FaceVertexAlphaData',fvad,...
'EdgeAlpha','flat',...
'LineWidth',1.5,...
'FaceColor','red',...
'EdgeColor','blue');
end
view(3);
camlight
Im using r2015a but the problem also occurs with r2016a.
Did I get the patch function wrong? Have you also noticed it? Is this a matlab problem?
Thank you very much in advance.

 Akzeptierte Antwort

Xiao
Xiao am 13 Jun. 2016
Bearbeitet: Walter Roberson am 13 Jun. 2016

1 Stimme

This is the intended behavior. There are two rule that determine this behavior:
  1. When the ‘EdgeColor’ is ‘flat’, the color/alpha of an edge is determined by the vertex that precedes the edge.
  2. When two edges overlap within a single patch, all but the edge belonging to the first face are discarded:
  • duplicate edges are edges which share a vertex
  • if you define two vertices at the same point, they are not considered the same vertex.
The second rule appears to be missing from the documentation. We will make sure to update the documentation to clarify the correct behavior.
Here is what is happening in more detail:
In the figure only one edge is transparent and the remaining edges are opaque. The transparent edge connects vertices 5 to 1.
If you separate the faces in the first patch into separate faces you get 12 edges:
Face 1 – Edge from vertex 1 to 2 – should be opaque because of vertex 1
Face 1 – Edge from vertex 2 to 5 – should be opaque because of vertex 2
Face 1 – Edge from vertex 5 to 1 – should be transparent because of vertex 5
Face 2 – Edge from vertex 2 to 3 – should be opaque because of vertex 2
Face 2 – Edge from vertex 3 to 5 – should be opaque because of vertex 3
Face 2 – Edge from vertex 5 to 2 – would be transparent because of vertex 5, but duplicate edge (Face 1) discarded
Face 3 – Edge from vertex 3 to 4 – should be opaque because of vertex 3
Face 3 – Edge from vertex 4 to 5 – should be opaque because of vertex 4
Face 3 – Edge from vertex 5 to 3 – would be transparent because of vertex 5, but duplicate edge (Face 2) discarded
Face 4 – Edge from vertex 4 to 1 – should be opaque because of vertex 4
Face 4 – Edge from vertex 1 to 5 – should be opaque because of vertex 1, but duplicate edge (Face 1) discarded
Face 4 – Edge from vertex 5 to 4 – would be transparent because of vertex 5, but duplicate edge (Face 3) discarded
The result is that the edge from 5 to 1 is transparent, while the remaining edges are opaque.

Weitere Antworten (0)

Gefragt:

am 31 Mai 2016

Bearbeitet:

am 13 Jun. 2016

Community Treasure Hunt

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

Start Hunting!

Translated by