The attached code adds a NNSearch method to the tree that allows users to find the rectangles that are closest to an input rectangle. The distance metric is a euclidean distance. The method is based on a best first search algorithm and therefore should be optimal.
The interface is structure in the same style as the existing Search method. It takes an input rectangle in the same format as Search as well as a callback. The callback has the same syntax as the callback required for the Search method, but takes an additional parameter which is the square euclidean distance.
The attached code adds a NNSearch method to the tree that allows users to find the rectangles that are closest to an input rectangle. The distance metric is a euclidean distance. The method is based on a best first search algorithm and therefore should be optimal.
The interface is structure in the same style as the existing Search method. It takes an input rectangle in the same format as Search as well as a callback. The callback has the same syntax as the callback required for the Search method, but takes an additional parameter which is the square euclidean distance.