如何用孔表示多边形? [英] How to represent a polygon with hole(s)?

查看:162
本文介绍了如何用孔表示多边形?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通常使用在向量(2 * 1或1 * 2矩阵)中将其顶点按CW或CCW排序的多边形.但是,如何在向量中声明带孔的多边形?

It's usually popular to work with polygons with their vertices sorted CW or CCW in vectors(2*1 or 1*2 matrices). However, how to state polygons with holes in vectors?

我将在这些多边形上应用各种处理,所以我想要一种可以轻松或有效地工作的表示方式(即,如何在程序中声明这种多边形以简化算法? )

I'm going to apply various process on these polygons, so I want a way of representing with which I could work easily or efficiently.(i.e how to state that kind of polygons in my program in order to ease my algorithms?)

多边形是2D的,我正在用MATLAB编程.

polygons are 2D and I'm programming in MATLAB.

我要计算这些多边形(有无)的可见度图孔).

EDIT 1 : I'm going to calculate visibility graph of these polygons(with or without holes).

推荐答案

正如其他人提到的那样,带有孔的多边形可以表示为外部边界,外加零个或多个内部边界,所有这些边界互不重叠*.如果您使用非零绕组数来确定内部/外部,请确保在内部指定内部边界与外部边界的方向相反(外部为逆时针,内部为逆时针,反之亦然),以便孔内的轮廓积分为零.

As others have mentioned, a polygon with holes can be represented as an exterior boundary, plus zero or more interior boundaries, all of which are mutually nonoverlapping*. If you use nonzero winding number to determine inside/outside, be sure to specify your interior boundaries in the opposite direction as the exterior boundaries (counterclockwise for exterior and clockwise for interior, or vice-versa) so that the contour integrals are zero inside the holes.

仅供参考,在OpenGIS简单功能规范( PDF ).

FYI, tis kind of definition/representation has been formalized in the OpenGIS Simple Features Specification (PDF).

就表示形式而言:

我可能会有一个K Nx2矩阵的单元格数组,其中单元格数组中的第一个元素是外部边界,而单元格数组中的其余元素(如果有)是内部边界.我会使用单元格数组,因为每个边界上的点数可能不相同.

I'd probably have a cell array of K Nx2 matrices, where the first element in the cell array is the exterior boundary, and the remaining elements (if any) in the cell array are the interior boundaries. I would use a cell array because there may not be the same number of points on each boundary.

* nonoverlapping =除个别点外,例如正方形内的钻石:

*nonoverlapping = except at individual points, e.g. a diamond inside a square:

这篇关于如何用孔表示多边形?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆