0
$\begingroup$

I found this image online:

enter image description here

and I would like to recreate it in mathematica. Is there an easy way to create this kind of circle packing in mathematica wihtout calculating all the individual radii? I found multiple examples of circle packings in mathematica but they are all based on using the same radius for each packed circle.

$\endgroup$
2
  • $\begingroup$ It seems that you would have to know at least 1 radius, or maybe even a set of possible radii, no? What is your expected functionality? What would you input and expect to be output? What work (code) have you done so far and what problems are you having with that code? Please post the code & other relevant information for us to see how to help you, thanks! $\endgroup$ May 30, 2021 at 18:18
  • 3
    $\begingroup$ There must be rules describing the sequence of radii and positions. When we know the rules we can create code. I can try to guess. Given the center circle, the radius of the next smaller circle is chosen, so that 7 circles can be placed around the center circle. Then the rule changes. The next ring of circles consists of circles with 2 different radii, with 2 largder followed by one smaller circle. But it is not clear how to choose the radii. And the over next ring seems to use the same rules. $\endgroup$ May 30, 2021 at 18:36

1 Answer 1

4
$\begingroup$

An alternative interpretation of the question: let's be lazy and compute the circles' pattern from the image.

img=Import["https://i.stack.imgur.com/kDMPt.png"]
ctds=#2&@@@ComponentMeasurements[{img,MorphologicalComponents[
img,.6]},"Centroid",Abs[#Circularity-1]<.1\[And]#Area>200&]

Most of the triangles have area <200, and all the circles have area >200. I used HighlightImage[img,ctds] to see this,

centroids

The thickness of the lines seems consistent, so adding 2 (about the thickness of the lines, in pixels) to each radius seems to work:

Graphics[Circle[#[[2,1]],#[[2,2]]+2]&/@ComponentMeasurements[
{img,MorphologicalComponents[img,.6]},{"Centroid",
"EquivalentDiskRadius"},Abs[#Circularity-1]<.1\[And]#Area>200&]]

circles

This is quick and dirty. In reality, intuition+Mathematica (as opposed to just asking Mathematica to numerically find centroids) is a more beautiful thing. I think it'd be pretty quick to bin the radii and centers along precise circles (they vary by ~.2 pixels due to anti-aliasing).

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.