How to find the area of intersection of 2 polygons without using polyshape?

8 ビュー (過去 30 日間)
Aravind Varma Dantuluri
Aravind Varma Dantuluri 2024 年 9 月 21 日
コメント済み: Shubham 2024 年 9 月 23 日
I have 2 polygons. One of them is smaller convex polygon and has <10 vertices. The other is enormous with 27 million vertices. This polygon has holes and is concave.
To find the intersection between 2 polygons, I would normally create their respective polyshape objects and use the intersection, and area functions to accomplish the task.
However, creating the polyshape of the big polygon is hanging my system. What alternatives do I have to find the area of intersection of the 2 polygons?

回答 (1 件)

Shubham
Shubham 2024 年 9 月 21 日
編集済み: Shubham 2024 年 9 月 21 日
Hey Aravind,
I understand that you want to compute area of intersection between two polygons having high number of vertices. In order to achieve this, do the following:
  • Reduce the number of vertices present in the polygon while maintaining the shape of the polygon. Remove the duplicate vertices by using the "simplify" function in MATLAB: https://www.mathworks.com/help/matlab/ref/polyshape.simplify.html
  • You can further reduce the the number of vertices of the polygon while maintaining overall shape, however the polygon would not have 100% accurate area. Refer to the following File Exchange submission which simplifies the polygon to a specified number of vertices: https://www.mathworks.com/matlabcentral/fileexchange/45342-polygon-simplification
  • If the above two steps does not help in reducing the complexity of the polygon, then compute the exact region present inside of the smaller polygon. We are only interested in the region of the large polygon being present inside the smaller one. For instance, check the following figures which demonstrates this idea:
  • Compute the vertices present inside the shape by using "inpolygon" or "isinterior" functions in MATLAB: https://www.mathworks.com/help/matlab/ref/inpolygon.html
  • Compute the intersection points of the polyshape by using "polyxpoly" function. Check for the individual line segments of the large polygon with the smaller one. You can optimize this by using parallel processing and being selective of the line segments associated with the points already inside the smaller polygon.
  • Once you have all the desired intersection points, you can create a small polyshape out of it and calculate its area.
Happy coding!
  2 件のコメント
Aravind Varma Dantuluri
Aravind Varma Dantuluri 2024 年 9 月 23 日
Thank you. I will check these suggestions out
Shubham
Shubham 2024 年 9 月 23 日
Sure, Do reach out if you have further queries, I'll be happy to help you.

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

カテゴリ

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

製品


リリース

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by