Pregunta

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.

¿Fue útil?

Solución 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.

Otros consejos

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

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top