Patch with holes

24 visualizzazioni (ultimi 30 giorni)
Ronen
Ronen il 25 Lug 2011
Risposto: Chad Greene il 24 Mag 2018
Your quick assistance please :
I got a group of vertices that actually define a square with a squared hole inside. I want the matlab to patch the vertices so it displays the square with the hole inside. As you may know, patch treats the vertices as if they define a closed shape, that is, without the hole inside. can I display that holed shape after all ? Thanks fellows

Risposte (4)

Chad Greene
Chad Greene il 24 Mag 2018
There's now a way to do this with standard Matlab functions. Starting with R2017b, the new polyshape function makes it easy. Just put NaNs between the outer shape and the holes.
x = [1 5 5 1 nan 2 4 3];
y = [1 1 6 6 nan 3 2 5];
pgon = polyshape(x,y);
plot(pgon)

the cyclist
the cyclist il 25 Lug 2011
Can you identify the vertices of the hole? If so, you could create a patch for the square, then overlay a patch with the hole.
You should post some code with what you have so far, to help us better understand what you've got.

Kelly Kearney
Kelly Kearney il 25 Lug 2011
If you have the Mapping Toolbox, look at poly2fv, then plot using patch's face/vertex syntax.
This function uses a mex-ed version of the General Polygon Clipper (GPC) library. If you don't have the Mapping Toolbox, and your polygons are complicated enough that triangulating by hand would not be possible, there's at least one FEX entry that seems also mex this library: Polygon Clipper... might be helpful.

Ronen
Ronen il 26 Lug 2011
Thanks, it goes very well so far. Now for one more small question : suppose I define a face (completely filled or with holes) using triangular composition (with that poly2fv etc.). would it be possible to extract the normal vector to the face ? In fact, how much information can I extract from my face (normal, which edges belong to outer-line and which aren't..)
  1 Commento
Kelly Kearney
Kelly Kearney il 27 Lug 2011
Assuming your polygon lies within a plane, then the surface normal should be easy to calculate (cross product of any two edges). As far as distinguishing outer and inner edges, Matlab uses clockwise vertices to define the outer face and counterclockwise vertices to define any inner faces. Once the polygon has been triangularized, then this wouldn't be so obvious to determine, but I assume you still have the original set of vertices.

Accedi per commentare.

Categorie

Scopri di più su Elementary Polygons in Help Center e File Exchange

Tag

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by