NearestNeighbors.jl icon indicating copy to clipboard operation
NearestNeighbors.jl copied to clipboard

Modify `inrange` to accept hyper-rectangle?

Open halleysfifthinc opened this issue 6 years ago • 3 comments

As I understand, inrange currently accepts a radius r which is used to determine if points exist within the hypersphere with radius r. I need to find the points existing within the hyperrectangle ϵ, a vector of the lengths of each dimension of the hyperrectangle.

I wanted to get your thoughts (and any pointers on how to go about implementing this) before I wasted any time.

halleysfifthinc avatar Mar 04 '18 00:03 halleysfifthinc

Curious to know was there a good solution? The issue was closed the same day it was opened.

jaakkor2 avatar Nov 15 '18 21:11 jaakkor2

Honestly, I don't recall what exactly I was working on at the time. I believe I realized I could do what I needed to do without a hyperrectangle inrange.

halleysfifthinc avatar Nov 16 '18 21:11 halleysfifthinc

This functionality would be useful. Could you @halleysfifthinc re-open the issue, otherwise I have to open a new issue.

I feel embarrassed to write something like this

idx_x = inrange(tree_x, x, dx)
idx_y = inrange(tree_y, y, dy)
#idx = intersect(idx_x, idx_y)
#idx = intersect(Set(idx_x), Set(idx_y))
idx = intersect(BitSet(idx_x), BitSet(idx_y)) # faster that the two above for my use case

jaakkor2 avatar Nov 26 '18 08:11 jaakkor2