I have a 2-dimensional array of bool like this

2-dimensional array of bool

The shape won't have any holes -- even if it has -- I'll ignore them. Now I want to find the Polygon embracing my shape:

embracing polygon

Is there any algorithm ready to use for this case? I couldn't find any, but I'm not sure whether I know the correct search-term for this task.

有帮助吗?

解决方案 2

After thinking about more a little I found it out and there is a O(n)-way to do it: Search row-wise for the first coordinate that contains at least one adjacent field set true. From there you can definitly take the first step to the right. From now on just walk around the field deciding what direction to walk next based on the four adjacent fields.

其他提示

You can use a delaunay triangulation and then remove the longest edges. I use the average of all edges multiply with a constant.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top