Your main problem can be described as follows: " Given a set of circles of varying radius, how does one place them within a larger circle, so that none of them overlap".
This is a difficult problem, but here you will find a solution for brute force:
- Sort circles by size
- Place the largest circle on the inside edge of the bounding circle
- For the remaining circles (r1), follow these steps:
- Iterates over all pairs of already placed circles (r2, r3) (including external)
- ( ) r1 + r2 r1 + r3 .
- .
, . , .