Problem (psuedo) How to find the outline of a set of tiles? Let's assume we have three tiles, at the x/y coordinates A[20,20], B[20,30] and C[30,30] (this will make a simple L-shape). Those points represent the centers of the tiles. Each tile has 4 vertexes: TL (top left), TR, BL (bottom left) and BR. Together, the 3 tiles have 8 unique (non-overlapping) vertexes.
We want the red line (path), defined by green dots (vertexes): http://img7.imageshack.us/img7/2469/lshapetiles.png
Needed solution The output of the algorithm should be a path that forms the outline shape of the tiles, consisting out of these vertexes - in this order: A TL, A TR, A BR, C TR, C BR, C BL, B BL, B TL (and optional, A TL again, to close). See the red line.
Possible solution(s) One option is to iterate over all the tiles, and for each tile check: + does it have a neighbor above? If not, at TL and TR to path + does it have a neighbor on the right? If not, at TR and BR to path + does it have a neighbor underneath? If not, at BL and BR to path + does it have a neighbor on the left? If not, at TL and BL to path
If you only add the found vertexes to the path if they're not added already yet, you've succesfully collected the unique vertexes for the path. However, they might be in the wrong order. This is a (the) problem.
Does someone know of a good solution (algorithm) for this?