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

12 vues (au cours des 30 derniers jours)
Aravind Varma Dantuluri
Aravind Varma Dantuluri le 21 Sep 2024
Commenté : Shubham le 23 Sep 2024
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?

Réponses (1)

Shubham
Shubham le 21 Sep 2024
Modifié(e) : Shubham le 21 Sep 2024
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 commentaires
Aravind Varma Dantuluri
Aravind Varma Dantuluri le 23 Sep 2024
Thank you. I will check these suggestions out
Shubham
Shubham le 23 Sep 2024
Sure, Do reach out if you have further queries, I'll be happy to help you.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Elementary Polygons dans Help Center et File Exchange

Produits


Version

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by