mourner / rbush

RBush — a high-performance JavaScript R-tree-based 2D spatial index for points and rectangles
MIT License
2.46k stars 237 forks source link

Definition of "intersection" could be made more explicit in the readme #128

Closed mindcitycode closed 1 year ago

mindcitycode commented 1 year ago

Those two rectangles

const one = { minX: 1, maxX: 2, minY: 1, maxY: 2 }
const two =  { minX: 0, maxX: 1, minY: 0, maxY: 1 }

do intersect according to rbush.

While this can be infered, reading the docs, from the fact that the algorithm works for both points and rectangles, it would be better if it was explicitly mentionned, for one could expect in cases such as the "one" and "two" boxes above, that having a zero width and height intersection (a point) would not be reported as intersection.

IvanSanchez commented 1 year ago

Note that in the GIS world, and specifically according to DE-9IM, two geometries intersect if they have at least one point in common. Compare against the concept of overlap. The language in rbush's docs is right.

mindcitycode commented 1 year ago

Very interesting read, thanks.

No doubt rbush doc is right from this point of view. A bit of clarification nevertheless wouldnt hurt for users coming from other domains. (And the same goes for the "collides" method).