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

Get the largest (ideally) set of non-overlaping rectangles?

damiendevienne opened this issue · comments

Thanks for these great functions !
I have been playing with rbush for the last few hours and I wonderd whether it was possible to think of an efficient (clever?) way of getting the largest set of elements that do not overlap one with each other.
Or at least a 'big enough' set, obtained by traversing the rbush tree and recursively removing overlapping rectangles?
Have you been thinking of this before? Is it something that could be of interest to others (than me!)?
Cheers,

What do you need this for, collision detection? The way we've been doing it usually is adding boxes greedily — start with an empty tree, then for each box, add it if it doesn't collide with an existing one (rbush.collides), repeat for all boxes.

Implementing an efficient algorithm for returning the largest set of non-overlapping bboxes from an existing tree is beyond the scope of the library.

Ok thanks a lot for that !