# Algorithm to Pack as Many Circular Segments into a Rectangular Box

I have a circle of radius $r$, and I have a bounding box with 4 sides, $a$, $b$, $c$ and $d$ as illustrated in the below diagram:

Here are a few constraints

$$r \geq a$$ $$r \geq b$$ $$c >> a$$ $$d >> a$$ $$c >> b$$ $$d >> b$$

$a$ and $b$ must be perpendicular to $d$ segment.

Another condition is that the the circular sectors must touch one of the long line segment ( the top line segment in this case), base on another long segment ( the bottom line segment in this case) and must not go out from it.

What is the algorithm/equation that allows me to generate all the circular sectors that

1. Touch one of the line segments
2. Won't go out from it
3. Fill the bounding box ( as defined by $a$, $b$, $c$ and $d$) as compactly as possible?
-
I think you haven't explicitly mentioned all the constraints that you are implicitly assuming. Apparently your box doesn't need to be a rectangle. Are you demanding (in (1)) that all segments are tangent to the same side of the box? Are you also demanding that all segments have their terminal ends on the same side of the box (as in the diagram)? And presumably this side must be the side opposite the side to which the segments are tangent. A single circular segment tangent to $a$ and terminating at $c$ and $d$ can fill an arbitrarily large proportion of the volume of the box. –  yasmar Dec 8 '10 at 17:11
@yasmar, not sure what you mean by the last sentence. Such a circle segment can't fill an arbitrarily large proportion because sooner or later it will go out from $c$. Also I've addressed your other concerns in the updated question. –  Graviton Dec 9 '10 at 1:16
"a and b must be tangential to d segment": that can't be right. Do you mean transversal? Perpendicular? –  Willie Wong Dec 9 '10 at 2:14
@It's perpendicular. –  Graviton Dec 9 '10 at 2:24
What you have drawn is not what is usually called a circular sector. Perhaps you mean a circular segment ? –  lhf Jun 7 '11 at 11:52