I am trying to implement an octree search to map my data from a coarse grid(say 20 points) to a fine grid (say more than 50 points). I have managed to construct the octree(using classes in c++) but now face the problem of querying it.
What I want is the closest 3 points from the coarse grid to every point on the fine grid and using the data values of these 3 points for finding the data value at the fine grid point. So now while querying I traverse the octree till I reach a leaf node. Assuming each of my leaf node has a minimum of three points(of the coarse grid), I will find the leaf node in which my fine grid point lies and compute the corresponding data values.
The problem now is that in some case the leaf node adjacent to the one I obtained for my fine grid point might contain point(or points) that are closer to it than the ones in the current leaf node. And determining this is what I haven't been able to get my head around.
I hope I was clear in my description and some good soul is able to help me out. Also if someone could point me towards querying the octree for points within a certain radius, would be of great help as well.
I am adding a picture to better explain my concern. The red points are the points in the octree and the blue point is the fine grid point's location after querying. Now I will be using the points in leaf node 1 to evaluate data values for this fine grid point whereas the leafnode 2 has points that are more close to the fine grid point.