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**2+aSize**2)**0.5)*0.5 bMed = ((bSize**2+bSize**2)**0.5)*0.5 # the distance between a pos and b pos distance = ((aPos-bPos)**2)+((aPos-bPos)**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!