I have a set of points denoted by (x y) coordinates in a space with a specified width and height, let's call this set s. Given any point p (p is not necessarily in s), I want to find the point q in s, such that the distance between p and q is minimized (i.e., find the closest point to p, that is in s).
Intuitively I feel as though I need to parse the entirety of s, and find the smallest distance by simply evaluating them all. For my application, this is unfortunately super slow.
I am wondering if there are any better ways to do this search? The only better way I can think is to organize the set s into a quadtree, find the leaf node that houses p, and check this leaf node's neighbour nodes for potential candidates for q. But that will be a lot of implementation :P