本文介绍了多边形的交集和并集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有定义了顶点的多边形,我需要计算它们的联合和交集的面积.最郁闷的是它在Mapping Toolbox中实现了,但我买不到.有谁知道如何制作一个快速算法来计算它?感谢您的时间.

I have polygons defined with their vertices's, and i need to calculate areas of their union and intersection. The most upsetting thing is that it is implemented in Mapping Toolbox, but i can't buy it. Does anyone knows how to make a fast algorithm to calculate it?Thank you for your time.

推荐答案

我找到了我的多边形的交点并添加了多边形内部/外部的顶点用于交叉/联合任务(检查多边形 1 的任何顶点是否位于多边形 2,反之亦然,使用inpolygon").然后将所有点转换为以矩阵的平均坐标为中心的极坐标,并按角度排序,这样它们就形成了连续的闭合轮廓.知道这一点,使用polyarea"很容易找到交叉/联合区域.

I found intersection points of my polygons and added vertices that are inside/outside polygons for intersection/union task (check if any of vertices of polygon 1 lies inside a polygon 2 and vice versa using 'inpolygon'). Then all points were transformed into polar coordinates with center in the mean coordinates of the matrix and sorted by angle, so that now they form consecutive closed contour. Knowing this it is easy to find intersection/union area using 'polyarea'.

这篇关于多边形的交集和并集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 23:07