I’m experimenting jmonkeyengine and I’ve come across the need to return all points (from a predefined large set of points) that fall within a bounding volume. It’s easy enough to create the volume itself but I’d like to get a map of all the contained points.
Does the community have any ideas? I’m happy to use other libraries if needs be, I’m drawn to jmonkey due to the community support and the BoundingCapsule shape.
Edit: I have considered iterating over all my Points and using .contains, unfortunately the space contains hundreds of thousands of points and relatively miniscule capsules. Surely there must be some clever maths I’m missing.
If you only need to do this once, you can’t get any better than checking each point against the bounding volume.
If you need to do multiple queries, you can improve the performance of your queries by setting up a spatial query structure. Note that you will first need to spend the time and memory to build and maintain your query structure, but that is fine if you can amortize the expense over a large number of queries.
Depending on your needs, you might want to use a grid, a quadtree, a K-d tree, or an R-tree to accelerate your spatial queries. The above is not an exhaustive list of acceleration structures, but it includes some of the most-used options.