Bucket Search Algorithm
Bucket search algorithm: Applicable for nearest neighbour problems
This script implements a bucket search algorithm. Two functions are included:
MakeBuckets – this function creates the 4D bucket structure. It has three input arguments: MakeBuckets returns an object containing the bucket structure. In addition to the buckets the object has the following extra properties which may be useful: FindBucket is a function which returns the bucket indices for a given point/node. It has two inputs: FindBucket returns an array containing 3 integer values. They represent the X, Y and Z bucket indices for the input node/point. Once the bucket indices are known the bucket of interest is given by: Bucket_Array[X_index][Y_index][Z_index]. In the example, the user inputs a search tolerence and then selects a node on one part and the script sketches the nearest node on the neighbouring part (within the tolerence). A timer is included for interest. Note if the search distance is large or unknown then for large problems the kd tree search algorithm is likely to be more efficient. |