C算法确定点阵中最大的多边形

标签 c algorithm

这是一个让我烦恼了一夜的问题。

给定一组点,说:

1 1 1 1
1 1 1 1
1 1 1 1
1 1 1 1

最大的多边形是一个 4x4 的正方形。为此:

0 0 1 1 1 
0 1 1 1 1
1 1 1 1 1  

最大的是梯形,但是也会有不规则的,其他的变化...

如何确定最大可能? (最大的意味着不能被任何其他多边形包围)我应该使用什么样的算法?

它们还需要其他属性,如面积、周长、凸面 (t/f) 和不变旋转数...


这是在说明中提供的,但我真的不明白它到底是关于什么的......

Call encoding any 2-dimensional array of size between between 2x2 and 50x50 (both dimensions can be different), all of whose elements are either 0 or 1. Call neighbour of a member m of an encoding any of the at most eight members of the array whose value is 1, and each of both indexes differs from m's corresponding index by at most 1. Given a particular encoding, we inductively determine for all natural numbers d the set of polygons of depth d (for this encoding) as follows:

Let a natural number d be given, and suppose that for all d0 < d, the set of polygons of depth d0 has been determined. Change in the encoding all 1's that determine those polygons to 0. Then the set of polygons of depth d is determined as the set of polygons which can be obtained from that encoding by connecting 1's with some of their neighbours in such a way that we obtain a maximal polygon (that is, a polygon which is not included in any other polygon obtained from that encoding by connecting 1's with some of their neighbours).

最佳答案

也许我太不耐烦了,但我发现你得到的指示很笨拙,我明白你为什么觉得它们难以理解。

您已经指定了一个答案,但这里有一些您可能希望探索的相关主题。

凸包可能是你想要的。凸包通常被描述为好像 2D 空间中的点都是钉板上的钉子。钉子外侧的橡皮筋形状就是凸包。

http://en.m.wikipedia.org/wiki/Convex_hull_algorithms

此外,缩小(或增大)1 并将其替换为 0 的操作听起来像是形态学上的“腐 eclipse ”操作。

http://en.m.wikipedia.org/wiki/Erosion_(morphology)

关于C算法确定点阵中最大的多边形,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19203394/

相关文章:

c - 如何处理 c 中的换行符和分隔符间距?

c - 用于从路径中提取文件名的可移植纯 C 函数

c - 使用 -O3 选项优化结构指针

python - 在至少 'x' 列中包含非零值的最大行集

python - 在Python中使用Ctypes读取Dll的双c结构

c - 在什么情况下(如果有的话)C 中前缀和后缀递增/递减运算符之间的性能存在差异?

algorithm - 学习元素顺序的排序算法?

algorithm - Dinic 算法实现和一个 spoj 难题

ruby - 如何有效地加入从 json 列表收到的 ruby​​ 散列

algorithm - 如何有效地连接两个二叉搜索树?