Jump to content
AntoineSfx

Packing circles of different radius

Recommended Posts

Is there a way to generate (instead of physically simulate by growing their radius..) a set of circles of different radius, densely packed ?

I didn't find a relationship between the centers of the circles in an ideally packed set of circles and Delaunay / Voronoi.  It's certainly a good start to use the Voronoi cells but it still requires some tweaking afterwards.  A quick approximation would work too, because I want to use this to copy objects onto another object, but I don't want too much interpenetration between the copies.

Maybe something like generating a bit more than expected, then removing the offending circles until no intersection is found.

 

Share this post


Link to post
Share on other sites
6 hours ago, AntoineSfx said:

Is there a way to generate (instead of physically simulate by growing their radius..) a set of circles of different radius, densely packed ?

I didn't find a relationship between the centers of the circles in an ideally packed set of circles and Delaunay / Voronoi.  It's certainly a good start to use the Voronoi cells but it still requires some tweaking afterwards.  A quick approximation would work too, because I want to use this to copy objects onto another object, but I don't want too much interpenetration between the copies.

Maybe something like generating a bit more than expected, then removing the offending circles until no intersection is found.

 

Interesting challenge again :-)

Maybe use a point wrangle, and use nearpoints to return, for each point, the closest point surrounding it. Then store an attribute with half of the distance between the 2 points. Call it firstRadius for this example.

Then in a second pass (another point wrangle) we can see if there is room to increase the firstRadius of each point, depending on the firstRadius of surrounding points. Store a list/array of, say, the 10 closest points of each points. And for each points of this list compare the distance between your current point (ptnum) and the point of the list you are iterating in, and the sum of their firstRadius attributes. Take the point for which this difference is minimal, and increase the firstRadius accordingly.

Then instance a sphere or a circle with the radius stored in FirstRadius.

Not sure if my explanations are clear... I haven’t tested, but I am curious to see if this works. Maybe tonight :-)

Edited by StepbyStepVFX

Share this post


Link to post
Share on other sites

I did this with crappy old Max (MCG)....suuuuuuuurely can be done in Houdini......Houdini should eat this for breakfast...

 

Share this post


Link to post
Share on other sites

I tried an algorithm that plays with the radius of circles given some fixed points, but it is not optimally packed. Moving the points on top of that would bring better results.... I share the file although that's not quite a good solution. To get a better solution I think it would require an algo that would be using an iterative process with both the radius and positions.

packedCircles.hip

Edited by StepbyStepVFX

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×