Hi There I’m trying to use the overlap command. But it sometimes fails in squares [image attached].
I wrote a code [attached] based on the distance between the centers of the squares and their medians. But unfortunately he also failed.
def SquaresOverlaps(a, b):
# positon of two squares
aPos = a.pos
bPos = b.pos
# sizes of two squ
aSize = a.size
bSize = b.size
# the 0.5 Median length of two squ
aMed = ((aSize[0]**2+aSize[1]**2)**0.5)*0.5
bMed = ((bSize[0]**2+bSize[1]**2)**0.5)*0.5
# the distance between a pos and b pos
distance = ((aPos[0]-bPos[0])**2)+((aPos[1]-bPos[1])**2)
# defining if a is ovelaping b
if distance >= aMed+bMed:
return False
else:
return True
I would be happy for your help in solving the problem, thanks!