Good!
Let's see I have a function that generates a list ( List A ) of coordinates in numpy .
[[1,1][1,6][3,5][5,7]]
< - (for example)
And I have another list ( B list ) with more coordinates (Also in numpy )
format
[[2,1][1,5][7,8][9,10][10,10][11,11]]
Then my goal is to pass the list A and a radius (of 1 for example) compare with the list B and tell me which points of the list A intersects with one of the list B . in this case, passing radio 1, I would say
list A [[1,1][1,6]]
intersects list [[2,1][1,5]]
I've thought it makes a function that generates the area of each point of the list A with that radius. and then I'll make you a convexhull ... but I do not know if there will be a faster and better function, since my list has more than 100,000 points.
The code I have is the following (but it is the non-optimal version)
def getRadius(cords,radio):
# print cords[1:] lado derecho
# print cords[:1] lado izquierdo
x = []
y = []
x.append(np.asscalar(cords[1:]) + radio/2)
x.append(np.asscalar(cords[1:]) - radio/2)
y.append(np.asscalar(cords[:1]) + radio/2)
y.append(np.asscalar(cords[:1]) - radio/2)
return(np.array(list(itertools.product(y, x))))
def getListNewCoords(listCoords,radio,Poids):
newList = []
for i in listCoords:
newCoords = getRadius(i,radio)
inHull = in_hull(Poids,newCoords)
z = Poids[inHull]
if not z:
newList.append(i)
return(newList)