2

I am interested in particle algorithms like the N-Body, and SPH. One of the important steps in these applications is, given a query point, to find the particles lying within a specified sphere of radius 'h'.

Now I have heard that Octrees are good spatial data structures for problems like N-body or SPH.

But after the octree construction, I cannot understand how the "locate particles within a radius" step is performed . Can someone please point me to some references, papers or articles for doing this step?

smilingbuddha
  • 14,334
  • 33
  • 112
  • 189

2 Answers2

2

Guessing that Octree contains 3dPoint objects: "locate particles within a radius 3 of Point p" can be expressed as "Return all points contained in Octreecells touching or intersecting with Sphere(center p, radius r)" To test if a cell intersects a sphere:

dx,dy,dz = 0;
if (pX < minX of Cell)
    dx = |px - minX|
else if (px > maxX of Cell)
    dx = |px-maxX|
Same for other dimensions

return (|dx,dy,dz|<=r)
BuddhaWithBigBelly
  • 345
  • 1
  • 6
  • 15
-1

k-d trees are also good data structures to use for this and are commonly used for nearest neighbor searches.

James Johnston
  • 9,264
  • 9
  • 48
  • 76