python_prtree icon indicating copy to clipboard operation
python_prtree copied to clipboard

Consider a “query_pairs” method

Open matsupin opened this issue 10 months ago • 1 comments

Hi,

Really interesting tool that you have there, thank you for making it available!

I wonder if it would be possible to introduce a query_pairs type method in a future version, like the one provided by cKDTree in the scipy.spatial module. Ideally, it would return a numpy array of index pairs.

This could prove particularly useful for quickly accessing colliding pairs of AABBs without having to perform any further manipulation in Python.

Currently, to do this I need to use np.vectorize, np.repeat and np.concatenate to convert the nested lists from batch_query into flat arrays and then apply a boolean mask to remove duplicate and undesired pairs. Unfortunately, this whole process cancels out any performance gains from the parallelized C++ calculations.

Please, let me know!

matsupin avatar Feb 03 '25 09:02 matsupin

Hi, @matsupin

Thank you for your suggestion! I will adding a method query_intersections() that would efficiently enumerate pairs of intersecting AABBs.

Since AABB intersection checks are based on simple bounding box overlap rather than distance calculations, I believe parameters like r (radius) and p (norm) from query_pairs() are unnecessary for this method.

Would this approach meet your needs? Let me know if you have any specific requirements or use cases I should consider!

atksh avatar Feb 12 '25 01:02 atksh