4

How can we draw 20 circles which have random radius in a specified range, with random positions. All centers must be in a square with side=10 (for example centimeter):

every overlapping between any circles (their circumference) can happen is it possible to color the circumstances with random colors?!

Unbelievable
  • 4,847
  • 1
  • 20
  • 46
  • 2
    This doesn't sound as a question that is particularly aimed at Mathematica; it's more algorithmic of nature and one could develop solutions using brain, pen and paper. Could you indicate what the specific Mathematica angle is here and what you have done so far? – Sjoerd C. de Vries Jun 02 '15 at 13:07
  • Ok, I am editing that. – Unbelievable Jun 02 '15 at 13:21
  • at the first I produced a table contained 20 random numbers (as centers) in a range and 20 others (as radius) and plotted (pairs) of them. But I am going to obtain a short way to that. – Unbelievable Jun 02 '15 at 13:26
  • 1
    I see that you changed your question so it doesn't include non-intersecting circles, but I wanted to point out this tangentially related question nonetheless: Generating visually pleasing circle packs. It would be worth a look for the sheer artistic value alone. – MarcoB Jun 02 '15 at 15:44

1 Answers1

8
centers = RandomReal[{0, 10}, {20, 2}];
radii   = RandomReal[{0, 1}, 20];
Graphics[{MapThread[{RGBColor@@RandomReal[{0, 1}, 3], Circle@##} &, {centers, radii}], 
         FaceForm[Transparent], EdgeForm[Red], 
         Polygon[{{0, 0}, {0, 10}, {10, 10}, {10, 0}, {0, 0}}]}]

Mathematica graphics

Edit

If you want disjoint circles you may go with something like:

SeedRandom[42];
f := {RandomReal[{0, 10}, 2], RandomReal[{0, 1}]}
l = {f};
While[
  Length@l < 100,
  While[k = f;
   Not[And @@ ((# + k)[[2]] < EuclideanDistance[#[[1]], k[[1]]] & /@ l)]];
   AppendTo[l, k]];
Graphics[{Circle @@@ l, FaceForm[Transparent], EdgeForm[Red], 
         Polygon[{{0, 0}, {0, 10}, {10, 10}, {10, 0}, {0, 0}}]}]

Mathematica graphics

Dr. belisarius
  • 115,881
  • 13
  • 203
  • 453