Calculate minimum horizontal distance to avoid overlap when rotating adjacent rectangles

geometryrectanglestrigonometry

I have two equally sized rectangles $(2$m $\times$ $1$m$)$ adjacent to each other. When both rectangles are rotated around their centre point, they can overlap, for example at $50$ degrees:

Adjacent rectangles rotated

Knowing only the dimensions of the rectangles and the angle of rotation, is it possible to determine the minimum horizontal distance, $X$, the blue rectangle needs to move to avoid overlap?

I've tried making triangles for basic trigonometry using the centre points (green circles) and creating normals but can't seem to figure out a correct method if it is even possible.

Rectangle dimensions

Best Answer

When you are rotating a rectangle in XY plane around its center point, the distance to the four corners (half of the diagonal) will be the radius of the circle as the four corners will always be on the circumference of the circle. If you do not want these rectangles to overlap, you must make sure that the circles drawn do not intersect each other. The minimum distance between them will be when the circles are just touching each other.

Say, the length of the rectangles is a and width is b.

Radius of both circles will be, $r = \frac{1}{2}\sqrt {a^2+b^2}$

The horizontal distance between them in the initial position you have shown will be,

$d = 2r - b = \sqrt {a^2+b^2} - b$

EDIT: to include min. distance at individual points as requested -

$d_{\theta} = 2r|sin(\theta+\alpha)|-b$

where $\theta$ is the angle of rotation from the vertical axis.
$\alpha$ is the angle between the long axis and the diagonal of the rectangle,
$r sin \alpha = \frac{b}{2}$; $r cos \alpha = \frac{a}{2}$.

So when they are vertical as in the first diagram of yours, $\theta = 0$. That means, $d_0 = 0$.

When you rotate by $(90^0-\alpha)$ from vertical position, the distance between them has to be maximum and that is what is given in my solution above.

When they are horizontal ($\theta = 90^0$), distance between them is
$d_{\frac{\pi}{2}} = 2r|sin(90^0+\alpha)| - b = 2rcos \alpha - b = a - b$.

You can also come up with it for rectangles of different dimensions on the same line.