Circle/Sphere Packing.

Next
 From:  Barry-H
11874.1 
Hi,
attached a script to circle/sphere pack a closed planar curve.
There are instructions included.
Cheers
Barry
Modification to Js file circle growth function modified so Zip as been updated.
Just replace BHCirclePacking.js with new one.


EDITED: 9 Apr by BARRY-H

Attachments:

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Frenchy Pilou (PILOU)
11874.2 
Very cool! ;)



---
Pilou
Is beautiful that please without concept!
My Moi French Site
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  MO (MO_TE)
11874.3 In reply to 11874.1 
Thank you for sharing it Barry. Works nicely

What's the difference between random and dynamic modes?
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Barry-H
11874.4 In reply to 11874.3 
Hi Mo.
I developed the script with AI copilot and this is part of the description I got for Dynamic.
Advantages of Dynamic Mode Over Random Mode
Dynamic mode is still stochastic, but it has directional intelligence that Random mode lacks.
That gives it several practical advantages in speed, structure, and fill quality.

1. Higher Efficiency (Fewer Wasted Samples)
Random mode throws candidates uniformly everywhere, so most attempts fail once the packing gets dense.
Dynamic mode:
• biases sampling toward promising directions,
• avoids dense regions,
• reuses successful direction vectors.
Result:
You get more valid placements per sample, which means faster fills, especially in mid‑to‑high density regions.

2. Better Boundary Following
Random mode doesn’t “know” where the boundary is — it just hopes to land near it.
Dynamic mode:
• tends to push outward,
• aligns with curvature,
• naturally traces the boundary shape.
Result:
You get cleaner edge bands and fewer “holes” near the boundary.

3. More Structured, Flow‑Like Patterns
Random mode produces pure noise.
Dynamic mode:
• carries momentum from previous placements,
• forms directional streaks,
• creates emergent flow lines.
Result:
You get visually coherent patterns that feel intentional rather than chaotic.
This is why designers often prefer Dynamic mode for aesthetic fills.

4. More Stable Density Distribution
Random mode can cluster or leave sparse patches because it has no memory.
Dynamic mode:
• avoids backtracking into dense areas,
• tends to fill gaps more systematically,
• maintains smoother local density.
Result:
You get more even coverage with fewer accidental voids.

5. Better Performance in Narrow or Complex Shapes
Cheers
Barry
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  PaQ
11874.5 In reply to 11874.4 
Is there a fancy (quick) method to compute this kind of packing ?
My method is pretty lame here, involving a lots of iteration (basically I'm packing circles one by one until threr is no space left).
It does gives some nice result tho, wish it could be done in a more elegant way.




  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Frenchy Pilou (PILOU)
11874.6 
And if you retake this result as figure in a new process you will obtain a very elegant fractal geometric nifty pattern! :)
---
Pilou
Is beautiful that please without concept!
My Moi French Site
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  PaQ
11874.7 In reply to 11874.6 
mmm if I repack circles in those circles I would end up with the exact same result ? not sure to follow :P
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Barry-H
11874.8 
Hi,
I have modified the JS file see post11874.1
Just replace old with new.
Cheers
Barry
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
11874.9 In reply to 11874.8 
Thanks for sharing it Barry!
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Barry-H
11874.10 In reply to 11874.9 
Hi Michael,
your guidance at the beginning was a big help.
Cheers
Barry
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Frenchy Pilou (PILOU)
11874.11 In reply to 11874.7 
@PaQ
This green form will play now the the role of the circle! :)

etc...goto the fractalium abbys! :)

Filling or not depending of the final image wished!

EDITED: 27 Dec 2025 by PILOU

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  PaQ
11874.12 In reply to 11874.11 
Oh I see. Packing circles is not "that" complicated, packing random shapes that's something different :P ... it's basically something a uv packer do, but they usually only test a bunch of fixed rotation (+90 degree for example).
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  MO (MO_TE)
11874.13 In reply to 11874.4 
Hi Barry,
Thanks for the info. Indeed, it is a very nice script. I tried several times to make a circle packing node, but I always ended up filling a simple rectangular or circular base shape. (Filling arbitrary shapes involves hard calculations.) I never thought that packing arbitrary shapes could be done with the help of the tools inside MoI (boolean intersection).
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Frenchy Pilou (PILOU)
11874.14 
A cool script will be fall any objects in a box for obtain o sort of packing objects without intersection!
---
Pilou
Is beautiful that please without concept!
My Moi French Site
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  MO (MO_TE)
11874.15 In reply to 11874.5 
Hi PaQ
NodeEditor Plus includes a circle packing node that can be useful for arbitrary shapes, especially shapes with holes. The node called "Image Circles" was developed by Wayne Hill. It uses an image to generate a circle packing pattern.
Here, I've just imported your screenshot into Gimp and used "Fuzzy Select" and "Bucket Fill" tools to make a PNG image with a transparent background.
Load the image into "Image Circles" by clicking on the node's white area and change the settings. Then connect this node to an "Output" node and press the Run button to get the desired result.
If you want to keep the results, press the Apply button.

Tip: Double click on the canvas to open the search box.
Image Attachments:
Size: 104.1 KB, Downloaded: 26 times, Dimensions: 1450x862px
Size: 145 KB, Downloaded: 53 times, Dimensions: 1528x513px
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
 From:  PaQ
11874.16 In reply to 11874.15 
Ho that's very interesting.
Thanks for posting, I definitively need to check that out, it's probably way smarter than my method !
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged
 

Reply to All Reply to All