Let's say I have an array as follows (each small array is [x, y] ):
var myPoints = [[25, 28], [26, 26], [70, 40], [50, 50], [300, 300], [285, 350], [1000, 1000]];
Let's say I need to trim the array to 4 points. (this is a small example, my acutal array has thousands of points). How could I thin out an array based on density, so more points are removed from areas with points closer to each other, and fewer points are removed from areas with lower density?
In this case (with decreasing the specified array from 8 to 4 elements), I expect the returned array to look something like this:
var thinnedPoints = [[25, 28], [70, 40], [300, 300], [1000, 1000]];
My idea of ββhow to approach this would be to create a dictionary that displays the minimum distance to another point on it (for example, a point close to another point would have a minimum minimum distance), and then sort the dictionary based on the bottom minimum then delete each element of the n'tn dictionary.
The problem with this approach is that I do not know how to efficiently generate the distance to the nearest other point value for each point.
Is there an efficient way to generate these values, or maybe there is another way to approach this problem based on density based on density?
Thanks!