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.
find polygon from bool-grid
-
28-06-2022 - |
Вопрос
I have a 2-dimensional array of bool like this
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:
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
Другие советы
You can use a delaunay triangulation and then remove the longest edges. I use the average of all edges multiply with a constant.
Не связан с StackOverflow