Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding widest empty straight path through a set of point

I'm creating a simple game and come up with this problem while designing AI for my game: Given a set of N points inside a rectangle in the Cartesian coordinate, i need to find the widest straight path through this rectangle. The path must be empty (i.e not containing any point).

enter image description here

enter image description here

I wonder if are there any efficient algorithm to solve this problem? Can you suggest any keyword/ paper/ anything related to this problem?

EDIT: The rectangle is always defined by 4 points in its corner. I added an image for illustration. the path in the above pictures are the determined by two red lines

like image 201
Chan Le Avatar asked Apr 27 '11 02:04

Chan Le


2 Answers

This is the widest empty corridor problem. Houle and Maciel gave an O(n2)-time, O(n)-space algorithm in a 1988 tech report entitled "Finding the widest empty corridor through a set of points", which seems not to be available online. Fortunately, Janardan and Preparata describe this algorithm in Section 4 of their paper Widest-corridor problems, which is available.

like image 149
some guy Avatar answered Sep 28 '22 08:09

some guy


Loop through all pairs of points. Construct a line l through the pair. (^1) On each side of l, either there are other points, or not. If not, then there is not a path on that side of l. If there are other points, loop through points calculating the perpendicular distance d from l to each such point. Record the minimum d. That is the widest path on that side of l. Continue looping through all pairs, comparing widest path for that pair with the previous widest path.

This algorithm can be considered naive and runs in O(n^3) time.

Edit: The above algorithm misses a case. At ^1 above, insert: "Construct two lines perpendicular to l through each point of the pair. If there is no third point between the lines, then record distance d between the points. This constitutes a path." Continue the algorithm at ^1. With additional case, algorithm is still O(n^3)

like image 40
ThomasMcLeod Avatar answered Sep 28 '22 10:09

ThomasMcLeod