MATLAB Answers

0

How to plot the exterior edges only of an alphaShape

Mustafa Al Homsi さんによって質問されました 2019 年 3 月 18 日
最新アクティビティ John D'Errico
さんによって コメントされました 2019 年 3 月 20 日
I am trying to plot an alphaShape using the code below
x = rand(10,1)*5;
y = rand(10,1)*5;
shape = alphaShape(x,y);
alphas = alphaSpectrum(shape);
shape.Alpha = alphas(1);
ax = app.mapPlt;
plot(shape,'Parent',ax,'EdgeColor','none','LineStyle','--','LineWidth',0.75);
When I plot this shape, the exterior edges are blank. Changing the last line to
plot(shape,'Parent',ax,'EdgeColor','black','LineStyle','--','LineWidth',0.75);
will plot the exterior esdges but it will also plot the the interior edges. Is there a way to plot the exterior edges only?

  0 件のコメント

サインイン to comment.

製品


リリース

R2018b

1 件の回答

回答者: John D'Errico
2019 年 3 月 19 日
編集済み: John D'Errico
2019 年 3 月 20 日

When you have a problem like this, learn how to investigate what you can do with the class.
x = rand(10,1)*5;
y = rand(10,1)*5;
shape = alphaShape(x,y);
>> methods(shape)
Methods for class alphaShape:
alphaShape alphaTriangulation boundaryFacets inShape numRegions plot volume
alphaSpectrum area criticalAlpha nearestNeighbor perimeter surfaceArea
methods tells you what methods have been provided. Here, do any of them sound interesting? I hope so.
edges = boundaryFacets(shape)
edges =
1 4
4 8
8 6
6 10
10 3
3 9
9 2
2 5
5 1
plot(x(edges),y(edges),'-ro')
hold on
plot(x,y,'.')
So a fairly boring alpha shape, since all but one of the points were on the perimeter.

  5 件のコメント

I need to fill in the inside of the shape and not leave it blank. I usually do that by setting the "FaceColor" patch property when I plot it as an alphaShape but with this approch I can't do that unless you know of another way to do it.
To be more specific, here is the code I am using
x = rand(10,1)*5;
y = rand(10,1)*5;
shape = alphaShape(x,y);
alphas = alphaSpectrum(shape);
shape.Alpha = alphas(1);
plot(shape,'EdgeColor','none','FaceAlpha',0.4,'FaceColor','black','LineStyle','--','LineWidth',0.75);
and this code generates the plot below with no edges
figure1.jpg
If I remove the 'EdgeColor' specifcation, the code will plot all edges on the perimiter and inside the shape as shown below
figure2.jpg
I obviously can plot the alphaShape with no edges and then just plot the perimeter edges as an array of points like you have shown. I just thought there might be a more straightforward way to manipulate the alphaShape plot command.
John D'Errico
2019 年 3 月 20 日
You know how to plot the shape, filled, with NO edges.
Do you know how to then add a second set of edges on top?
help hold
So just then add the perimeter edges on top. Make them any color you wish.

サインイン to comment.



Translated by