Wow man, thanks for this. Yes, it is for a phone case. I’m about to go back and set the plane and see what that produces. The whole idea is to get the pack pretty dense within a range of radii. Thanks again for the effort my man!

I added the on plane goal and it seemed to help a lot. Once again my incomplete knowledge of grasshopper was the issue. If there are any intersections, I can’t tell. Now the only thing that would cause clipping would be to add more circles than can be fit into the boundary. Is there a way to “solve” for the perfect circle count?

i dont think that you can get a perfect amount that easy, sooner or later a situation below will happen which would need an adjustment of all the surrounding circles to fit. daniel may cook up something iterative… but that would mean that the entire amount of circles would have to adjust to one perfect equilibrium.

Its not possible to have a circle tangent to more than three circles of different radii. Of course that all depends on the order of circle creation. In the above example I believe the circles were created right to left leaving the gap you pointed out as adding that tangency would result in having to break one of the other three tangencies.

I agree - if the circle radii are prescribed in advance, it won’t generally be possible to achieve a *compact* circle packing (when all the gaps between the circles are 3 sided).

If you allow >3 sided gaps things are a little easier.

Personally I find true compact circle packings more elegant compared to packings with 4 sided gaps, and they have deep connections to some nice mathematics, such as discrete analytic functions.

There’s a nice theorem due to Koebe that says that to every triangulation of the sphere there

corresponds a circle packing, and this packing is unique up to *Moebius transformations*:

I found I could also use compact circle packings to generate these systems of sliding equilateral triangles:

here showing the underlying circle pattern:

Also, if you generate a pair of circle packings with the same connectivity and different boundaries, it gives you a conformal map between the two shapes:

Hi Daniel,

This might be a trivial question - but how do you ensure/generate same connectivity with different boundaries?

Hi Timothy,

The easiest way is to mesh one shape, then take that mesh and pull its boundary points to the boundary curve of the other shape.

Ah, I see, thanks! I was thinking there was somehow a mapping between the populating (of the vertices) and the edges generation steps. I was perhaps overthinking this but didn’t understand how the pulling of points would always work on more complex base shapes.

It can actually sometimes be useful to pull to a tweened curve, so there isn’t a sudden jump that could cause the mesh to fold over itself.

I want to improve it a bit first, but I’ll post an example like the one above soon.

pulling to a tween curve sounds like a great intermediate step (although i guess tweening has its own issues to begin with) - thanks and looking forward to an example!

Hi Daniel,

is there any .gh definition you can offer yet?

I see that you are latest commentor in this thread. Could you by any chance achieve this .gh?

Actually my problem is not even close to this tread, I was looking for any answers to the wrong place. I just created a new submission for my goal. If you can take a look, I would really appreciate that. Thank you.

Thank you very much for this example, while playing with this script I noticed that the compact packing have a higher chance to fail near sharp corners like near the “home button” this this particular shape, is that something unavoidable with or something which can be solved with a better connectivity mesh?

Hi @texasvodkas

The boundary curve input for the compact circle packing goal keeps each of the outer circles of the packing touching this curve at a single point.

If you want some circles to touch the boundary at 2 points (so they nestle into the sharp corners), this needs another goal.

Here’s one I made which keeps a point at equal distance from a pair of curves. So if you identify the corners and the parts of the boundary either side, it can keep a circle touching the boundary on both.

circpack_corner.gh (14.9 KB)

Note though that once we pin some circles in the corners like this, no perfect compact circle packing with given connectivity generally exists. For that the points need to have the freedom to slide around the boundary.

Also - I realised that when using the boundary curve input for the circle packing goal, the orientation of the curve matters (as it uses the relation between the curve tangent and the mesh normal to keep the circles on the inside of the curve). For a future release I’ll try and make it detect the correct curve orientation automatically, but currently you might sometimes have to flip the curve.

Here’s a slight adjustment to the above definition to inset the surface before remeshing which helps the circles move less during the optimization.

circpack_corner_offset.gh (17.7 KB)

Tagging also @assistant.petercoffi , as I think this is also relevant to the other discussion here Compact circle packing on complex surface - #5 by assistant.petercoffi