I have a Numpy array a of shape 5000 * 3 that contains the coordinates of 5000 points in 3D space. I also have another array b of shape 512 * 3 that again contains the coordinates of another 512 points in that 3D space. I wish to select 512 points from a that are closest to points in b. Meaning that to find a Numpy array c of shape 512 * 3 from the points in a such that for each 1<=i<=512, c[i] is the closest point to b[i], from all of the 5000 points in a.
To find c, there is one way to compare point by point and find the closest but it is very slow. I wish to find another faster way to approach this.