The overlap of two unit squares is a rectangle with area 1/16.
Find the minimum distance between their centers.
The intuitively obvious solution turned out to be wrong.
Since the shape of the overlap is a rectangle, no rotations other than 90 degrees are possible, so ignore rotations. Other shapes would be much more complicated. But given a rectangle, intuitively it seems the two squares are side by side then pushed together until they overlap by 1/16 of a unit.
The distance between the centers is 15/16 = 0.9375. I expected this to be the answer.
If instead the 2 squares start oriented diagonally, touching only at one vertex, then one is moved at a 45 degree angle, the overlap will be a (1/4) by (1/4) square and the distance would be (3/4)*√2 =~ 1.06
So far, it intuitively seems that 15/16 is the answer.
But ...
Suppose the second square starts side by side with the first square; it is moved up a distance t then horizontally to make a rectangular overlap area = 1/16
Say the lower left corner of square 1 is at (0,0) and that of square 2 starts at (1,0). After moving, that corner of square 2 is at ( (1  1/(1616t)) , t )
or ( (1516t)/(1616t) , t)
The dist^2 = (225  480t + 256t^2)/(256  512t + 256t^2) + t^2
dist^2 = (225  480t + 256t^2 + 256^2  512^3 + 256t^4) / (1616t)^2
Running the code below finds a minimum for distance. Since several early runs showed that t was about .06, instead of checking all t values from 0 to 1, I just checked up to .1.
Minimum distance found: 0.9354143466934853
(less than 15/16)

def dist(t):
return ((225  480*t + 256*t**2)/(256  512*t + 256*t**2) + t**2)**.5
mint = 1000
mind = 1000
for i in range(10000000):
t = i/10000000
d = dist(t)
if d < mind:
mind = d
mint = t
print(mint,mind)
min t value min distance
0.06698729 0.9354143466934853
Edited on May 14, 2023, 12:48 pm

Posted by Larry
on 20230512 15:06:00 