# Determine if it is possible to fit 2 circles in a rectangle

I have the following problem:

Given a Rectangle with $L$ length and $W$ width and $2$ circles with $r_1$ and $r_2$ radius, determine if it's possible to fit these two circles inside the rectangle.

I realized that:

If $2r_1 > L$ or $2r_1 > W$ or $2r_2 > L$ or $2r_2 > W,$ then it is not possible to fit the circles in the rectangle. Thus if $2 r_1 + 2r_2 \leq L$ and $2r_1 + 2r_2 \leq W,$ they can fit vertically or horizontally.

My doubt is to check if they can fit diagonally? How do I get it ?

-
We can sometimes do better diagonally. For example, we can fit two circles with radius $1$ diagonally in a square of side $2+\sqrt{2}\approx 3.414$. – André Nicolas Jul 18 '12 at 18:38

Here is my thought process here:

It's true that the best way to proceed will always be to stick one circle 'in one corner' of the rectangle and to try to fit the other circle 'in the opposite corner.' I take this for granted. It is very easy to understand where the center of a circle will go when the circle is 'tucked in a corner,' as both sides of the rectangle will be tangent to the circles. For example, if the rectangle is at coordinates $(0,0), (0,h), (l,0),$ and $(l,h)$, and a circle of radius $r_1$ is in the bottom-left corner, then the coordinates of its center will be $(r_1, r_1)$. If another circle, this one of radius $r_2$, is tucked in the top-right corner, the coordinates of it's center will be at $(l-r_2, h-r_2)$.

So one has to check two things: one has to make sure that both circles fit in the rectangle itself (without worrying about overlap), and then one has to make sure that the distance between the centers is greater than the sum of the radii.

So $2r_1, 2r_2 \leq l,h$ and $d[(r_1,r_1), (l-r_2,h-r_2)] \geq r_1 + r_2$ should be necessary and sufficient, where I let $d(\cdot, \cdot)$ denote the distance function.

-
Unless I misunderstand, shouldn't it be $d[(r_1,r_1), (l-r_2,h-r_2)] \geq r_1+r_2$? – David Spencer Jul 18 '12 at 18:45
It's a good Idea, but if I take a $7*8$ rectangle and 2 circles with radius $2$ and $3$, in my book it says it's impossible to fit in the rectangle, but in this idea, the distance between the 2 poins $(2,2)$ and $(5,6)$ it's distance is $3.6056$, and the 'limit' distance for fit is $6.0$ proving that it's wrong, is my book or the idea which is wrong ? – aajjbb Jul 18 '12 at 19:17
@DavidSpencer: Yes - you'd think that after having explicitly typed out "greater than the sum of the radii" I wouldn't make such an error. Thank you! – mixedmath Jul 18 '12 at 19:19
@aajjbb: I'm sorry, as David Spencer mentioned, I actually meant that the distance should be greater than the sum of the radii. I changed that for you - and $3.6 < 5$, so they won't fit – mixedmath Jul 18 '12 at 19:20
I've got it, Thank you so much! – aajjbb Jul 18 '12 at 19:46

Can you see that your best configuration is with the two circles in opposite corners, and that the limit is with the circles tangent to one another? Draw that tangent configuration and see if you can find a use for Pythagoras ... then work out which way the inequality goes. You might want to set $R=r_1+r_2$, which looks as though it could simplify the algebra.

-