Skip to main content
Commonmark migration
Source Link
added 90 characters in body
Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929

To get horizontal coordinates of the centers of the circles/spheres (1) Accumulate the diameters of circles/spheres in odd and even positions separately, (2) shift the second list by an arbitrary amount ( byby the average of the horizontal positions the two leftmost circles/spheres below) and, (3) riffle the two lists to getand (4) subtract the centersradii from the resulting list:

SeedRandom[1]
randomradii = RandomSample[Range @ 20, 10];
centers = Module[{origins = {0, Mean[Sort[#][[{1, 2}]]]}}, Riffle @@ 
   (Function[x, origins[[x]] + Accumulate[2 #[[x ;; ;; 2]]]] /@ {1, 2})] - #] &@ randomradii;
Graphics[MapIndexed[{Thick, ColorData[97]@#2[[1]], 
  Circle[{centers[[#2[[1]]]] - #, 0}, #]} &, randomradii]]

Graphics3D[MapIndexed[{Opacity[.5], ColorData[97]@#2[[1]], 
   Sphere[{centers[[#2[[1]]]] - #, 0, 0}, #]} &, randomradii], 
  Boxed -> False, ViewPoint -> Front]

(1) Accumulate the diameters of circles/spheres in odd and even positions separately, (2) shift the second list by an arbitrary amount ( by the average of the horizontal positions the two leftmost circles/spheres below) and (3) riffle the two lists to get the centers:

SeedRandom[1]
randomradii = RandomSample[Range @ 20, 10];
centers = Module[{origins = {0, Mean[Sort[#][[{1, 2}]]]}}, Riffle @@ 
   (Function[x, origins[[x]] + Accumulate[2 #[[x ;; ;; 2]]]] /@ {1, 2})] &@ randomradii;
Graphics[MapIndexed[{Thick, ColorData[97]@#2[[1]], 
  Circle[{centers[[#2[[1]]]] - #, 0}, #]} &, randomradii]]

Graphics3D[MapIndexed[{Opacity[.5], ColorData[97]@#2[[1]], 
   Sphere[{centers[[#2[[1]]]] - #, 0, 0}, #]} &, randomradii], 
  Boxed -> False, ViewPoint -> Front]

To get horizontal coordinates of the centers of the circles/spheres (1) Accumulate the diameters of circles/spheres in odd and even positions separately, (2) shift the second list by an arbitrary amount (by the average of the horizontal positions the two leftmost circles/spheres below), (3) riffle the two lists and (4) subtract the radii from the resulting list:

SeedRandom[1]
randomradii = RandomSample[Range @ 20, 10];
centers = Module[{origins = {0, Mean[Sort[#][[{1, 2}]]]}}, Riffle @@ 
 (Function[x, origins[[x]] + Accumulate[2 #[[x ;; ;; 2]]]] /@ {1, 2}) - #] &@ randomradii;
Graphics[MapIndexed[{Thick, ColorData[97]@#2[[1]], 
  Circle[{centers[[#2[[1]]]], 0}, #]} &, randomradii]]

Graphics3D[MapIndexed[{Opacity[.5], ColorData[97]@#2[[1]], 
   Sphere[{centers[[#2[[1]]]], 0, 0}, #]} &, randomradii], 
  Boxed -> False, ViewPoint -> Front]
added 210 characters in body
Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929

With sorted radii, for example,

SeedRandom[1]
randomradii = Sort@ RandomChoice[Range @ 20, 10];

we get

enter image description here

With sorted radii, for example,

SeedRandom[1]
randomradii = Sort@ RandomChoice[Range @ 20, 10];

we get

enter image description here

added 38 characters in body
Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929
Loading
added 1241 characters in body
Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929
Loading
deleted 22 characters in body
Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929
Loading
deleted 12 characters in body
Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929
Loading
added 56 characters in body
Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929
Loading
added 777 characters in body
Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929
Loading
deleted 46 characters in body
Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929
Loading
deleted 3 characters in body
Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929
Loading
added 560 characters in body
Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929
Loading
added 205 characters in body
Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929
Loading
Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929
Loading