Circle packing (or stacking) on a dome with gravity-like attraction?

Tried to adapt a circle packing script with an anchor centered below a dome to pull evenly downward. Having several issues though, I think I’m fundamentally missing something, like my Strengths are competing poorly and I have overlapping happening. Could anyone point out the problem or lead me toward a better method?

Just looking for circle stacking, like Connect Four, on a mesh.

cp with (25.4 KB)

1 Like

Try a little search before asking, there’s load of topics about CP

Hi @closedcurve
there were a couple of issues with your file-

The wrong radii were being used to draw the circles on the output points.
The “V” output of the solver is all the points used by the simulation. This will not generally be the same points in the same order as being used in the collision goal (because other goals used will add more points).
If you want to output the same list of points as used by the collision goal, in the same order, you can use a Show goal as shown.

Secondly, attraction to the centre point of the sphere will have very little effect because you also have them constrained on the surface of the sphere, which directly conflicts with that.
If you want vertical gravity, use the Load goal as shown

cp with (18.7 KB)


@Petrol I share the sentiment, I’ve created and posted on many circle packing topics over the years, I am an enthusiast to say the least. This was a little different objective from what I’ve encountered before or seen documented under the terminology I was searching. At least in terms of packing/stacking on a surface.

@DanielPiker Thanks for pointing that out and Load is exactly what I was missing. This is perfect.

1 Like

Any way to limit the circles from not leaving the surface? (24.5 KB)


This is so cool! Please add it in the next version of Kangaroo!

I’m having an incontinence on curvy surfaces, I notice around tight bends it leaks circles. I’ve tried adjusting several settings to accommodate for this, including substantially upping the strength on your C# script but they will drop no matter what. Do you have any advice?


Cirlces_gravity_boundary (31.3 KB)

Although you’re showing the surface in your image, the packing in your definition was actually happening on a rather low resolution mesh approximation of this, and only being projected onto the surface after the simulation:

Note that when you input a Brep or surface to the mesh input parameter of the OnMesh goal, it uses the default Grasshopper mesh settings, which may not be suitable for your geometry.
Because that cuts off the corners, there are areas where the boundary is far from the smooth boundary curve the circles are colliding with, hence the ones you are getting slipping through.

It’s better here to do the meshing upstream so you can control exactly what mesh you are pulling to.
Here you see if you use a finer mesh resolution the leaking doesn’t happen because the boundary of the mesh matches the the collision curve. (30.8 KB)


Ah, that makes sense! Thank you for the explanation and workaround.