Neighborhood Search

Your browser does not support the HTML5 canvas tag.
0.00 ms
0
0.025

Neighborhood search using spatial hashing:

This example shows how the neighborhood of a particle is determined using spatial hashing [THM+03]. For each particle we want to find its neighbors within a given radius (the support radius of the kernel function).

In each step all particles are added to a spatial grid using a cell size $s$ that equals the support radius of the SPH kernel function. The index $(i, j)$ of the grid cell of a particle is determined as $$i = \lfloor x/s \rfloor,\quad\quad j = \lfloor y/s \rfloor.$$ Since each particle is in a grid cell of size $s \times s$, the neighbors in a radius of $s$ must lie in one of the 9 neighboring cells (in 3D: 27 cells). Therefore, to get the neighbors for a particle $p$ in cell $(i,j)$, we test for all particles in the 9 neighboring cells $(i\pm1, j\pm1)$ if their distance to $p$ is less than $s$.

References

  • [THM+03] Matthias Teschner, Bruno Heidelberger, Matthias Müller, Danat Pomeranets, Markus Gross. Optimized Spatial Hashing for Collision Detection of Deformable Objects. In Proceedings of VMV, 2003.