i have a list that contains number of tuples.
POIs = [(3,2),(6,2),(6,5),(10,1),(12,-2),(5,7)]
the tuples inside of POIs are 2D-coordinates of detected objects. What i'm trying to do is to check the eucludian distance between these objects so that if the distance between each two objects is smaller than 3, then the two objects are considered as one and the new coordinate would be the average distance between them.
Conceptionally,this looks like a clustering problem and requires to examine the distance of every object with the other and calculate the distance like
# example, hier only the first two points are considered
d = np.sqrt(np.abs(POIs[0][0]-POIs[1][0]) + np.abs(POIs[0][1]-POIs[1][1]))
if (d<3):
POIs[0] = (POIs[0][0]+POIs[1][0]/2 , POIs[0][1]+POIs[1][1]/2)
So, my question is if this could be computationally optimized as this becomes worse when the list includes a large number of tuples/objects