2

I have a program where a 2D shape is represented by an R-trees. I want to be able to efficiently detect whether a shape is completely contained within another shape. Is this possible with R-tree?

settinghead
  • 95
  • 1
  • 6
  • In the general case: No, you can't determin if a shape is completly contained within another shape, as an R-Tree uses the minimal bounding box (the smallest rectangle big enough to enclose the shape) to represent/organize shapes; concave polygons (shapes) can fall into the same bounding box even if one is not completly contained in the other (try it with pen and paper, you get an example really quick). Look at the question Emir Akaydın linked to. – Tom Regner Nov 15 '11 at 09:25

2 Answers2

1

if the shape is a child element, it means it is contained under parent element. if you have a problem with detecting a polygon inside another polygon, you can check this link.

Check if polygon is inside a polygon

Community
  • 1
  • 1
Emir Akaydın
  • 5,708
  • 1
  • 29
  • 57
1

R-trees work on bounding boxes. So for polygon-inside-polygon tests, it can serve as an efficient filtering step, but not answer the exact query. It produces candidates, and skips sure misses efficiently.

Has QUIT--Anony-Mousse
  • 76,138
  • 12
  • 138
  • 194