I am working on a positioning system. The input I have is a dict which will give us circles of radius d1 from point(x1,y1) and so on. The output I want is an array(similar to a 2D coordinate system) in which the intersecting area is marked 1 and rest is 0. I tried this:
xsize=3000
ysize=2000
lis={(x1,y1):d1,(x2,y2):d2,(x3,y3):d3}
array=np.zeros((xsize,ysize))
for i in range(xsize-1):
for j in range(ysize-1):
for element in lis:
if distance((i,j),element)<=(lis[element]):
array[i][j]=1
else:
array[i][j]=0
break
def distance(p1,p2):
return math.sqrt((p1[0]-p2[0])**2+(p1[1]-p2[1])**2)
The only problem is that the array is large and takes way too long(no. of loops is in 10 millions), especially on a raspberry pi, otherwise this works. Is there any way to do it using openCV and an image and then draw circles to get the intersecting area faster?
It has to be python 2.x.