How can I fill many polygons with a particular colour within a periodically bounded box in matlab ?

1 ビュー (過去 30 日間)
SOUMYADIPTA RAY
SOUMYADIPTA RAY 2022 年 5 月 12 日
回答済み: Image Analyst 2022 年 5 月 16 日
I tried with the 'patch' or 'fill' function. But the main problem is, for the periodically bounded box, there are many situations where half of a polygon is near the left boundary of the box and rest part of that polygon is near the right most boundary of the box, which is just opposite to the left part. The 'fill' or 'patch' function simply connects the two parts of the polygon and fills the colour throughout the box !! I just want to fill the colour in the two parts of the same polygon separately( so that virtually the two parts has to be treated as two separate polygons). I am attaching a figure, where I tried to fill the polygons through the 'patch' function. You can see the problem for the near-boundary polygons. If anyone can help me regardig the issue, it would be great.
  2 件のコメント
SOUMYADIPTA RAY
SOUMYADIPTA RAY 2022 年 5 月 16 日
Thank you for your comment. Yeah, actually there is no periodic boundary condition in my raw data. But to visualize the whole system of polygons, I make make a transformation so that all the polygons comes within the box and and due to that the half polygons near the bounday are generated. Thus the half polygons are continuous indeed. How can I adjust it ?
I am attaching a data file consisting of one single polygon in box of length 6 and the polygon have 3 halves in the box. How can I colour fill the 3 halves ?

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

回答 (1 件)

Image Analyst
Image Analyst 2022 年 5 月 16 日
You need to get the coordinates of the polygons on the edge of the image and close them by tacking on the first point to the end of the coordinate list. Then the polygon will be closed and should get filled.

Community Treasure Hunt

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

Start Hunting!

Translated by