2

I am dealing with a programming challenge, In that I need to find the region which the given point belongs to. There is some methods here for that problem.

Point Location

So I decide to use slab decomposition, It is fast enough, easier to implement, and space is not much of a problem for me. However, I am having trouble about where to start. Here is an example of slab decomposition from a pdf file made by UC Santa Barbara.

Slab decomposition

I store the geometrical shape in a node dictionary like an undirected graph (Using coordinates).

defaultdict(<type 'list'>, {(4.0, 5.0): [(1.0, 2.0), (2.0, 3.0), (3.0, 5.0)],
 (1.0, 2.0): [(2.0, 3.0), (2.0, 4.0), (3.0, 5.0), (4.0, 5.0)],
 (2.0, 3.0): [(1.0, 2.0), (2.0, 4.0), (4.0, 5.0)],
 (2.0, 4.0): [(1.0, 2.0), (2.0, 3.0), (3.0, 5.0)],
 (3.0, 5.0): [(1.0, 2.0), (2.0, 4.0), (4.0, 5.0)]})

Like so. (Still don't know if a edges list would be better ?)

Now I know how to solve the problem, however having difficulty deciding which way to implement because the input will be a very complex geometrical shape and finding the point will be expensive in cpu resources.

I decided to store each point (sorted using x coordinates) in a sorted list(using bisect). To acquire slabs. However, I could not find a way to find how the slabs intersect with the region edges, or how to partition the slab as shown in the picture. Actually I did find a way but it did not feel feasible to me. I could check the edges which starts from the left of the slab and end at the right of it. Which means the edge is crossing the slab. This is fine, however to accomplish that I would have to check almost the half of the vertices each time a new node is given and the regions increase. So This method sounded like a failure to me. There is also the problem to knowing which region does the region in the slab belongs to. Given that we are doing all this to avoid checking all the regions one-by-one to improve speed.

If you could give me some ideas on the subject, I don't require any piece of code. I just need advice from experienced users here. I am stuck because I can't be sure how to implement it and I don't want to start it the wrong way and rewrite it whole. (I can assure you this is no homework.)

Note1: I could not be sure about the data structure, should I make a structure for regions?, or for points ? or edges ? Or do I need a structure for a creating a search tree ? What would I have to store in this structure ?

Note2: I know how to find which slabs the point lies. I also know how to find the point with binary search inside the slabs. I am lacking more conseptual knowledge, hence experience. Like how to represent regions in the first place.

Thanks in advance.

HEKTO
  • 3,876
  • 2
  • 24
  • 45
Max Paython
  • 1,595
  • 2
  • 13
  • 25

2 Answers2

0

I would advise to use your vertices only to reference too. Use an edge list to represent the graph and assign a left and right incident region to each edge. Now use these edges in your slab decomposition. As soon as you find your slab and your slab part you know also its region as both edges near your point reference to it.

gue
  • 1,868
  • 1
  • 16
  • 21
0

If you know that your data will be used many times to locate multiple points, then it'll make sense to preprocess the original planar graph and decompose it into slabs. Then the data structure problem you're facing will be reduced to a slab representation problem.

And what is a slab? It's actually an one-dimensional sequence of edges. So, you'll reduce the original problem to two binary searches - the first one in the slabs array, and the second one - in the edge array. The binary search in the edge array should be modified a little bit - you'll need to find a pair of edges, bounding the test point from the top and from the bottom (I'm referring to your picture here) as closely as possible.

And of course, you'll need to store references to original face labels somewhere in the edge array.

HEKTO
  • 3,876
  • 2
  • 24
  • 45