mourner / rbush

RBush — a high-performance JavaScript R-tree-based 2D spatial index for points and rectangles

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Custom element support

mudi77 opened this issue · comments

Hi,

I was glad that I found this powerful and tiny library and from beginning I relied on this statement or feature : "var tree = rbush(9, ['[0]', '[1]', '[0]', '[1]']);" - to incorporate custom element defined by svg paths

so I put together some local test but seems it is not working as I expected - my output from collide detection looks like element is always evaluated as rectangle. Is it expected behavior or am I doing something wrong ? does this algorithm support searching for custom elements let say irregular polygon?

Thank You
BR

While an R-tree data structure could be used for polygons, rbush only supports points and rectangles. To be fair to the author, it does state this several times in the readme!

Yes, R-tree is a data structure that can only incorporate rectangles and points. For most cases, it's enough to calculate a bounding box of your line/polygon and use that for indexing.