Blank areas with fill and patch in 2014b
9 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
After updating to version 2014b, my code containing fill or patch functions does not work properly. Try this example:
poly=[
6.00 0.00
6.00 4.00
7.00 5.00
8.00 5.00
8.00 0.50
9.00 0.50
9.00 5.00
7.00 5.00
8.00 6.00
9.50 5.00
9.50 0.50
10.0 0.50
10.0 0.00
9.50 0.00
6.00 0.00];
fill(poly(:,1),poly(:,2),'r')
The internal area is not filled properly, and the problem seems related to polygons with holes. In Matlab 2014a everything was ok.
1 comentario
Lisa Oberbroeckling
el 14 de Abr. de 2016
I've asked students to program their own Riemann Sum demo for years. Previous to R2014b, the following example code would work fine. Since then, it has the blank areas as discussed above. Taking out redundant vertices or adding vertices to "close the rectangles" does not help. Now the students have to use the fill command on each individual rectangle within their loops, as suggested by Image Analyst. This is unfortunate since we've been discussing "vectorization of code" in previous assignments. Any thoughts on when or if this may be fixed?
x=[0 0 1 1 1 1 2 2 2 2 3 3 3 3 4 4];
y=[0 1 1 0 0 2 2 0 0 3 3 0 0 4 4 0];
fill(x,y,'b')
Created using R2014a:
Created using R2015a:
Respuestas (4)
Doug Hull
el 6 de Nov. de 2014
Thank you for this simple reproduction case. Our developers in this area have noted this:
Our current rule for in-out test is a purely topological test based on Jordan-curve. Crossing of a single edge represents a flip in parity. Crossing of a double overlapping edge is ignored and does not change parity – such an edge is typically a bridge-edge that connects outer and inner loops – inner ones being holes.
If you have more about your intent, please contact me at hull@mathworks.com so I can note it in our internal database.
0 comentarios
Image Analyst
el 8 de Nov. de 2014
I suggest that whenever you have polygons where the edge intersects or crosses another edge, you plot it as two or more separate regions.
0 comentarios
Amro
el 4 de Dic. de 2014
Editada: Amro
el 4 de Dic. de 2014
The problem happens after the patch face is internally triangulated , when deciding which triangles are filled vs. holes. Try the following:
dt = delaunayTriangulation(poly);
triplot(dt)
text(poly(:,1), poly(:,2), cellstr(num2str((1:size(poly,1))')), ...
'Color','m', 'HorizontalAlign','left', 'VerticalAlign','bottom')
You can see that the triangle (2,3,4) corresponds to the one not filled in your example...
A simple workaround is to nudge the coordinates of the shared vertex 8, e.g:
poly(8,2) = poly(8,2) + 1e-6;
The offset is too small for you notice, but it should fix the bug for now.
0 comentarios
Ver también
Categorías
Más información sobre Triangulation Representation en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!