How to generate 2D grid map inside of a patch area

6 ビュー (過去 30 日間)
David Hermann
David Hermann 2022 年 4 月 7 日
回答済み: George Abrahams 2024 年 2 月 10 日
I would like to create a 2D grid map with equidistante points based on the faces and vertices of an patch.
In my case, I get a complex patch shape from a given figure (fig). With that I can read the vertices and faces
dataObjs = findobj(fig,'-property','XData');
faces = dataObjs.Faces;
vertices = dataObjs.Vertices;
Based on this information, a grid map (e.g. 1m grid) should be placed in the areas of that patch.
And this is where I get stuck.
One idea is that I put a grid map over the whole area and check which points are inside the patch area (like inShape), but I haven't found a suitable solution for this.

回答 (2 件)

KSSV
KSSV 2022 年 4 月 7 日
Read about inpolygon.
  1 件のコメント
David Hermann
David Hermann 2022 年 4 月 7 日
Thanks for the quick reply.
With inpolygon I cannot currently reproduce the complex form. I did it once via polyshape based on the vertices coordinate points, the polynomial areas look different then. The patch still uses the faces to connect the vertices.

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


George Abrahams
George Abrahams 2024 年 2 月 10 日
A 2D grid map of a patch sounds suspiciously like an image of the patch. Considering that you're first extracting the faces and vertices from a figure, most likely you want the either the getframe, saveas, or exportgraphics function.
If for some reason you need more control, you'll need a rasterization algorithm. If it's a 2D triangulation, you could use patch_rasterize on File Exchange. If it's a 3D triangulation, you could use my rendering toolbox on File Exchange.

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by