フィルターのクリア

fill a polygon with a hole

8 ビュー (過去 30 日間)
Qingping
Qingping 2014 年 2 月 26 日
回答済み: Steven Lord 2019 年 9 月 19 日
data=[
0.5, 0.8;
1.0, 0.0;
0.0, 0.0;
0.5, 0.8;
0.5, 0.4;
0.1, 0.1;
0.7, 0.1;
0.5, 0.4;
];
h=fill(data(:,1),data(:,2),'r')
the image is:
there is a line between dot(0.5,0.8) and (0.5,0.4) how to delete this line in prefectly? such as
I used the code set(h,'EdgeColor','r') to disappear this line.
  2 件のコメント
Azzi Abdelmalek
Azzi Abdelmalek 2014 年 2 月 26 日
What is the problem?
Qingping
Qingping 2014 年 2 月 28 日
I want to delete the line between two triangle in automatic!

サインインしてコメントする。

採用された回答

lvn
lvn 2014 年 2 月 28 日
Alternatively, you can remove all black lines (like that the figure looks good to me)
h=fill(data(:,1),data(:,2),'r','Linestyle','none')

その他の回答 (2 件)

Image Analyst
Image Analyst 2014 年 2 月 26 日
Simply get rid of the last 5 rows of your data.
data=[
0.5, 0.8;
1.0, 0.0;
0.0, 0.0;
];
h=fill(data(:,1),data(:,2),'r')
That's so simple I guess I'm missing something, or you are.
  4 件のコメント
Qingping
Qingping 2014 年 3 月 3 日
In this way, I want to confirm which one is outer object and which one is inner object.
Patrik Ek
Patrik Ek 2014 年 3 月 3 日
編集済み: Patrik Ek 2014 年 3 月 3 日
@Image Analyst: That was not expected, that matlab would not handle the case of polygons with holes, when plotting. I will remove my answer. I also did some research since it felt a bit incredulous that matlab could not do this. However the solution proposed by you were the most commonly recommended. +1 for that
@Qingping: Answer one is is of course the simplest one. However, to keep direction of the polygons you can check the direction or windiness or what you prefer to call it. The dierction should be opposite if the polygons are properly defined. Depending on standard the direction of the outer polygon may vary, but mathematics it is most often defined counter clockwise. However, MATLAB does in a number of occations define it the other way around (eg in mapping toolbox since this is more or less standard when working with maps)

サインインしてコメントする。


Steven Lord
Steven Lord 2019 年 9 月 19 日
Consider creating and plotting a polyshape. You will receive a warning but depending on how you've generated your data you may be able to avoid this.
data=[
0.5, 0.8;
1.0, 0.0;
0.0, 0.0;
0.5, 0.8;
0.5, 0.4;
0.1, 0.1;
0.7, 0.1;
0.5, 0.4;
];
p = polyshape(data);
plot(p)
Or, if you're building the outermost shape then subtracting away the inner holes:
outer=[
0.5, 0.8;
1.0, 0.0;
0.0, 0.0;
0.5, 0.8];
outerP = polyshape(outer);
hole = [
0.5, 0.4;
0.1, 0.1;
0.7, 0.1;
0.5, 0.4;
];
holeP = polyshape(hole);
totalP = subtract(outerP, holeP);
plot(totalP)

カテゴリ

Help Center および File ExchangeElementary Polygons についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by