So we have a reference set of 3D points (let's call it R), and many other sets of 3D points (let's call that set of sets of data points P, and each data set in that Pi).
The task is to return the Pi that minimizes the euclidean distance the data points in some Pi and R. The way I see it is this:
- For each point in Pi, compare to each point in R and find the minimum difference between two points.
- Sum up these minimum distances to reach the minimum total "difference" between Pi and R.
- The answer Pi is the one with the smallest difference.
But this is pretty crazy, since it means essentially looking at the distance between every point in R and every point in P, which could be thousands or millions. Surely I can do better than that.
I am working in Matlab, which I am not used to.
What is a better algorithm to use? Is there a data structure that is perfect for this? (for example a K-D tree?)