2

Given a circle centered at $A$, with radius $R_a$ and another radius $R_b$, I need to find a center for circle $B$ such that both circles are tangential, and the bounding box including both circles complies with ${height\over width}=k$

Dan
  • 213
  • I guess the radius $R_b$ is a given, and the point $B$ is to be found. So $B$ must lie on the circle centered at $A$ of radius $R_a+R_b$, and then by the "bounding box" do you mean the rectangle alligned with the $x,y$ axes which is the smallest containing both circles? There will be some limitations on the possible ratios $k$, but seems an interesting question, if I interpreted it correctly. +1 – coffeemath Mar 04 '13 at 19:45
  • @coffeemath yes, you got it right: bounding box = smallest rectangle aligned with x,y axes that contains both circles. I get in trouble when I try to express in a single equation the bbox constraint, and end up with several equations instead. It's also difficult to handle $Max$ and $Min$ in this context. – Dan Mar 05 '13 at 09:11

2 Answers2

1

There are really only two cases you have to consider. In one case, one circle touches two adjacent sides of the bounding box and the other circle touches the other two sides, hence a small variation in the placement of either circle will change both the width and height of the bounding box. In the other case, the smaller circle touches only one side of the bounding box and the other three sides touch the larger circle, so that a small variation in the position of either circle changes only one dimension of the bounding box, while the other dimension is determined by the larger radius alone.

If the two radii are equal then the first case covers all possibilities.

(I'm not considering the possibility that one circle is inside the other, since the only possible value of $k$ in that event is $1$ and that value is easily obtained by the first case listed above.)

For convenience, let $R = R_a + R_b$ and let $r = \max\{R_a, R_b\}.$ Assume Cartesian coordinates, and let $\Delta x$ be the difference of $x$-coordinates of the two circles' centers, $\Delta y$ the difference of their $y$-coordinates. Since the circles are externally tangent to each other, $$(\Delta x)^2 + (\Delta y)^2 = R^2.$$

Case 1

Now let's consider the first case, where each circle is touching at least two sides. It should be clear that the width of the bounding box is $R + |\Delta x|$ regardless of which circle is placed to the left, right, above, or below the other, and similarly the height of the bounding box is $R + |\Delta y|.$ I'll assume that the aspect ratio $k$ is meant to be the ratio of height to width, so we require $$k = \frac{R + |\Delta y|}{R + |\Delta x|}.$$

Solving for $|\Delta y|$ in this equation, we find that $$|\Delta y| = (k - 1)R + k \; |\Delta x|.$$ Plug this into the equation $(\Delta x)^2 + (\Delta y)^2 = R^2,$ and a little algebra gives us $$ (\Delta x)^2 + k(k-1)R \; |\Delta x| + \left(\frac{k^2}{2} - k\right)R^2 = 0. $$

Solve this as a quadratic equation in $|\Delta x|$ (discarding the negative root of the equation), and the relative placement of the two circles is then fully determined up to translations and reflections parallel to the axes.

Of course, this works only for certain values of $k.$ The fact that each circle must touch two sides imposes some constraints, namely, $|\Delta x| \geq |R_a - R_b|$ and $|\Delta y| \geq |R_a - R_b|.$ Note that $|R_a - R_b| = 2r - R.$ The extreme values of $k$ are achieved at the largest possible values of $|\Delta x|$ and $|\Delta y|,$ namely, when either $|\Delta x| = 2r - R$ or $|\Delta y| = 2r - R.$

When $|\Delta x| = 2r - R,$ the width of the bounding box is $2r$ and the height is $R + |\Delta y|.$ We know that $$ (\Delta y)^2 = R^2 - (\Delta x)^2 = R^2 - (2r - R)^2 = 4r(R-r), $$ and we know that $r$ and $R - r$ are $R_a$ and $R_b$ (not necessarily in that order), so $$ |\Delta y| = 2 \sqrt{R_a R_b}. $$ This gives us $$ k_1 = \frac{R + 2\sqrt{R_a R_b}}{2r}$$ as one of the bounds of $k.$ The other bound occurs when $|\Delta y| = 2r - R,$ which gives a bound $$ k_2 = \frac{2r}{R + 2\sqrt{R_a R_b}} = \frac{1}{k_1}. $$ (We could also conclude that $k_2 = \frac{1}{k_1}$ via a symmetry argument.) Therefore the "first case" occurs when $$ \frac{2r}{R + 2\sqrt{R_a R_b}} \leq k \leq \frac{R + 2\sqrt{R_a R_b}}{2r}. $$

Case 2a

The "second case" has two subcases. Let's consider the subcase where $|\Delta x| < 2r - R$ and therefore $k > \frac{R + 2\sqrt{R_a R_b}}{2r}.$ In this case we have $$k = \frac{R + |\Delta y|}{2r},$$ so $|\Delta y| = 2kr - R$ and $|\Delta x| = \sqrt{R^2 - (\Delta y)^2}.$

Case 2b

Similar reasoning for the subcase where $k < \frac{2r}{R + 2\sqrt{R_a R_b}}$ yields the solution $|\Delta x| = 2kr - R$ and $|\Delta y| = \sqrt{R^2 - (\Delta x)^2}.$

Unsolvable cases

Since the bounding box for the largest and smallest possible values of $k$ has one dimension equal to $2\max\{R_a, R_b\}$ and the other equal to $2R_a + 2R_b,$ we find that $k$ must satisfy $$\frac rR \leq k \leq \frac Rr.$$ For any given $R_a$ and $R_b$ it is not possible to construct a bounding box with an aspect ratio outside this interval. If we are allowed to vary the size of either of the circles, we can achieve any aspect ratio in the interval $\frac 12 \leq k \leq 2.$ No values of $R_a$ and $R_b$ permit $k$ to be outside this interval.

It may be of interest to observe that $R + 2\sqrt{R_a R_b} = \left(\sqrt{R_a} + \sqrt{R_b}\right)^2.$

David K
  • 108,155
1

By scaling one can assume that $R_a=1$, and we can put $R_b=r$. This answer only looks at the case where the second circle of radius $r$ is positioned so that its point of tangency with the unit circle (center at $A=(0,0)$ lies in the first quadrant. We also assume that the $r$ circle protudes enough in the $x$ direction so that the bbox needs to extend to the right of $x=1$, and that the $r$ circle is far enough down from the top that the entire $r$ circle lies below the line $y=1$.

The center of the $r$ circle lies at $((1+r) \cos \theta, (1+r) \sin \theta)$ where $\theta$ is the angle formed by the center of the $r$ circle, the origin, and the positive $x$ axis. Then the condition that the $r$ circle lies below $y=1$ is $$[1]\ \ \ r+(1+r)\sin \theta \le 1.$$ And the condition that the $r$ circle protrudes beyond the line $x=1$ is $$[2]\ \ \ r+(1+r)\cos \theta \ge 1.$$ The ratio $k$ under these assumptions comes from the fact that, in this situation, the height of the bbox is $2$ while its width, extending from $x=-1$ to the rightmost point of the $r$ circle, is $1+(1+r)\cos \theta +r$. This gives the ratio as $$k = \frac{2}{(1+r)(1+\cos \theta)},$$ which solves for $\cos \theta$ as $$\cos \theta=\frac{2}{k(1+r)}-1.$$ One can then find $\theta$ via arccos. Even in this simple case, it is necessary to know that [1] and [2] are satisfied, in order for the expression for $\cos \theta$ to achieve $k$ be valid. I've attempted to eliminate $\cos \theta$ and $\sin \theta$ from conditions [1] and [2], but it gets involved.

Note that here the value of $k$ must lie in the interval $[1/(1+r),1]$ in order for there to be a possible $r$ circle, where the smallest $k$ corresponds to the case where the $r$ circle is tangent to the unit circle at $(1,0)$. One naturally also needs $r<1$ or else the $r$ circle will extend beyond $y=1$ and change the formula for $k$.

It remains to look at other cases, for example the case wherein the $r$ circle extends both to the right of $x=1$ and above $y=1$. And the conditions [1] and [2] need to be restated without $\theta$, for a complete answer. There may be another way to look at this question, which would not involve so many cases and conditions.

coffeemath
  • 30,190
  • 2
  • 34
  • 53
  • Well, if the circle is in the first quadrant, the width and the height of the box are just $1+\max\bigl(1,(1+r)\cos\theta+r\bigr)$ and $1+\max\bigl(1,(1+r)\sin\theta+r\bigr)$. That covers all cases. –  May 10 '14 at 11:39
  • @Rahul Maybe add the above comment as a separate answer, if it can be shown to cover all cases as you say. My answer above, which I was not really satisfied with, would be improved on by another answer which covers all cases, since I had to restrict things. – coffeemath May 10 '14 at 18:38
  • I believe I have a solution for both the case handled here and the case where the smaller circle extends the bounding box both to the right of and above the larger circle. I use a slightly different approach, for example I write $\Delta x$ where you would write $(1+r)\cos\theta.$ It ends up not too bad if you don't mind writing things like $\sqrt{R_a R_b}.$ – David K Nov 26 '14 at 01:20