Distributing Spheres on a Surface with Offset and Collision Detection

Hi everyone, today I’m bringing a new challenge! As you can see from the attached screenshot, I need to create an object with spheres distributed on its surface. On the left, you can see the result of my Grasshopper script, while on the right, you see the manually created version.

Is there a way to make this Grasshopper script compatible with any object while ensuring the spheres are staggered? Additionally, I need to set up an alert to detect collisions between individual spheres so I can know when they touch each other.

P.S. The distance between the spheres must remain 1.1.


probem001.gh (13.0 KB)

Look for circle packing…

I tried, but I can’t achieve a result as precise as the one made using this Grasshopper script.

Is it specifically this regular hexagonal packing you want?
You can take a planar hexagonal grid of points and project them onto a surface.
However, the more curved your surface is, the more variation in spacing this will cause. For fairly flat shapes the variation will be small though.

Thank you very much for your response! Theoretically, I need to apply this pattern to both curved and relatively flat shapes And I need this pattern to follow the rule that the spheres must remain 1.1 mm apart from each other.

Here’s what I mean for the projection approach


project_grid.gh (25.4 KB)

As you see, they get further apart the more vertical the surface becomes.

You have to think about what precisely you mean by “the spheres must remain 1.1mm apart from each other”.
Which spheres?
For each sphere to be the same distance from their 6 closest neighbours, the only possibility is a regular hexagonal grid, but this cannot be wrapped onto a doubly curved surface without distortion of these distances.
So we are lead back to a sphere packing approach (for which you can find many examples by searching this forum), where we can make sure no 2 spheres are less than a certain distance apart, but typically each sphere will end up with 4 or 5 neighbours at the same distance, and 1 or 2 slightly further away.

Thank you very much for the explanation! Indeed, when calculating on a doubly curved surface, I realize that the distance between the spheres may vary slightly.

What I meant by “it must be 1.1mm” is that, visually, there shouldn’t be distances much larger than the reference distance.

I’ll look for some references on the forum regarding sphere packing. Do you have any specific ones you would recommend?

You can look for discussions of both sphere packing and circle packing, since to generate a circle packing on a curved surface, we typically first generate a sphere packing with the sphere centers on the surface, then generate circles at these points in the tangent plane to the surface.