How to calculate maximum size of circles in rectangle?

Reinier

New member
Joined
Jun 21, 2020
Messages
3
Hi,
For a given a rectangle with known width and height, I want to fit 4 circles of equal size regularly (see image) in such a way that the radius of the circles is maximized.
The aspect ratio of the rectangle is such that 4 circles fit in the latticed way shown in the image. So the 'most square' rectangle is shown on the left, and the most wide rectangle is shown on the right. The one in the middle is an arbitrary example of an intermediate rectangle.

How do I go about calculating the radius of the circles for given width and height of the rectangle? Or how do I calculate the angle between 2 circles and the horizontal? If I have the radius, I can calculate the angle, and vice versa.

rectangles.png

I can see some relations, but do not know how to go further from that:
With width w, height h, radius r and angle a:
h = 2 * r * (1 + sin(a))
w = 2 * r * (1 + 3 * cos(a))
so:
w / h = (1 + 3 * cos(a)) / (1 + sin(a))
If w and h are given, how do I solve for a ? I am afraid my trigonometry is insufficient for this...
For the image on the left, angle a is obviously 60 deg. For the image on the right, angle a is obviously 0 deg, but what about arbitrary intermediate rectangles?

And how does this generalize to 6, 8, 10, ... circles (for appropriately wider rectangles)?
 
Last edited:
Good work so far; it's just how I would have started.

Now, given a ratio w/h = r, you want to solve (1 + 3cos(a)) / (1 + sin(a)) = r. Clear fractions and rearrange, and you have

3 cos(a) - r sin(a) = r-1​

Now there are a couple standard ways to solve this; the basic idea is to compare the LHS with the angle sum formula

cos(x+y) = cos(x)cos(y) - sin(x)sin(y)​

I'll give you a chance to try working this out.

As for generalizing, basically just change the 3 to something bigger (assuming you are requiring this specific arrangement). For larger numbers of circles, other arrangements of the circles would be more efficient (see here for examples).
 
Thanks for the quick reply and the pointers.
So far, I didn't come up with the solution. Any more pointers would be appreciated.
When I was stuck figuring out how to use the angle sum formula in this, I tried using a pythagorean identity instead and then rewrite the equation to a quadratic formula, but the solutions I got were not correct (checked against known solutions).
 
Here is my hint:
Now, given a ratio w/h = r, you want to solve (1 + 3cos(a)) / (1 + sin(a)) = r. Clear fractions and rearrange, and you have

3 cos(a) - r sin(a) = r-1​

Now there are a couple standard ways to solve this; the basic idea is to compare the LHS with the angle sum formula

cos(x+y) = cos(x)cos(y) - sin(x)sin(y)​
Comparing [MATH]3\cos(a) - r\sin(a)[/MATH] to [MATH]\cos(x)\cos(y) - \sin(x)\sin(y)[/MATH], we wish that we could find an [MATH]x[/MATH] so that [MATH]\cos(x) = 3[/MATH] and [MATH]\sin(x) = r[/MATH]. But the Pythagorean identity says that can't happen, because [MATH]3^2 + r^2[/MATH] is not 1.

But we can scale those numbers so that they do work. By dividing them by [MATH]\sqrt{3^2 + r^2}[/MATH], the sum of squares will become 1.

So we divide both sides of the equation by that quantity:

[MATH]\frac{3}{\sqrt{3^2 + r^2}}\cos(a) - \frac{r}{\sqrt{3^2 + r^2}}\sin(a) = \frac{r-1}{\sqrt{3^2 + r^2}}[/MATH]​

Now if our "x", which I'll call [MATH]\theta[/MATH], is such that [MATH]cos(\theta) = \frac{3}{\sqrt{3^2 + r^2}}[/MATH] and [MATH]\sin(a) = \frac{r}{\sqrt{3^2 + r^2}}[/MATH], then the equation will become

[MATH]\cos(a + \theta) = \frac{r-1}{\sqrt{3^2 + r^2}}[/MATH]​

Can you take it from there?
 
Top