0

I have a Array[] with Rectangles which are all next to each other. I got this by using a flood fill.

I can get the corners of the rectangles to form a Point[] but then I would need an algorithm to find the outer most points. How do you check if the points are on a border? I know floodfill can calculate the border because it knows when to stop.

Help! I want a method that would take Rectangle[] and return Point[] of the outer most vertices so I can do graphics.DrawPolygon(pen, Point[]).

I just thought of a good algorithm. When I'm in a maze, I just follow the left wall until I find my way back to the starting point. Thanks stackoverflow. Taking the time to write the question really allows me to think creatively.

If anyone have the maze algorithm or know what its called, greatly appreciated.

I just found out about ray-casting. I think I'll be use that by casting vertically from leftmost rectangle to rightmost. Then cast horizontally from top to bottom.

bwang22
  • 79
  • 1
  • 10
  • what you need is `Convex Hull`. see if [this](http://stackoverflow.com/q/14671206/1043824) helps – inquisitive Mar 11 '14 at 05:39
  • I know about convex hull. However, I want to maintain the borders that are neat from the rectangles. If anyone have the maze algorithm or know what its called, greatly appreciated. – bwang22 Mar 11 '14 at 05:45

1 Answers1

0

Caveat I've got limited experience in this sort of thing, but personally I'd stay away from a recursive algorithum like a maze search and go back to a floodfill and make changes to that.

At some point the floodfill alg will determine that it's hit an edge. So I'd change the code so that it adds the found point to a new array. Normally it would breaking out of the iteration and move on to the next point.

Chris Moutray
  • 18,029
  • 7
  • 45
  • 66