Skip to main content

Voronoi Patterns in Bitbybit: Nature's Cells as Exact Geometry

· 11 min read
Three pieces made with Voronoi patterns in Bitbybit for 3D printing: a tapering hexagonal tea-light lantern with graded holes, an arm with a graded foam core cut open, and a strut lattice mount on its base plate

Scatter a few points over a sheet and give every spot on it to the point nearest to it. The sheet falls apart into regions, one around each point, and those regions are Voronoi cells. Nature draws them all the time: start many things growing at once, each from its own point and at the same speed, let each stop where it meets a neighbour, and every border ends up halfway between two starting points.

Bitbybit now builds those cells as exact geometry, in any planar face or any solid, and builds from them what nature builds: lace, cages, struts and foam. It is bitbybit.occt.patterns.voronoi, free in our MIT-licensed npm packages, and it works in Rete, Blockly and TypeScript.

Why nature draws them​

Much of what grows, dries or packs works the way described above, so patterns close to Voronoi cells turn up everywhere:

  • Giraffe skin, whose patches are polygons separated by narrow pale lines, much like cells with their edges drawn wide.
  • Dragonfly wings, where a thin membrane is held by veins, and cross veins divide it into small polygonal cells, finest along the leading edge.
  • Leaf veins, whose smallest veins enclose little islands of tissue, each fed from the veins around it.
  • Foam, packed cells sharing thin walls, each sealed from its neighbours.
  • Cracked mud, which shrinks toward many centres at once and cracks along the lines between them.
  • Honeycomb: seeds spaced evenly on a triangular grid give regular hexagons, the cell bees build.

Real cells are rarely all alike. Some start earlier or grow faster and take more than half the gap to a neighbour, and every pattern here can be graded the same way, so that cells, holes, struts or voids change size across a part.

Exact cells, in any face or solid​

Each cell is computed from its seed and its neighbours, then built as an exact face or solid of straight edges and planar faces. In a convex face of straight edges, a box or any convex solid of planar faces, every cell is cut to the boundary by the boundary's own lines and planes, and no boolean runs at all. A face with curved edges or holes, or any other solid, works too: only the cells that cross its boundary are cut to it, so a curved part costs about as many booleans as there are cells along its edge.

The Voronoi cells of a box, each an exact solid with flat faces, pulled apart to show themThe Voronoi cells of a sphere, pulled apart: the inner cells flat-faced, the outer ones keeping a piece of the round surface

Cells come as faces or solids, or as their shared edges and faces, each made once, for a drawing or a cut along the borders. Give the seeds weights and a heavier seed's cell grows at its neighbours' cost, still convex and straight-edged: power cells. Join every two seeds whose cells share an edge and you have the Delaunay triangulation, the Voronoi diagram's twin. And most functions have a twin that also reports what it built: every cell's state, its area or volume, its centroid and whether it was cut.

Seeds and the fields that grade them​

A pattern is decided by its seeds. They can come from anywhere, as a plain list of points, but most come from seeds2d in a face or seeds3d in a solid, placed at random, on a jittered grid, or by Poisson sampling, irregular but even with no clumps and no gaps, which is the look of most patterns nature makes. Rounds of Lloyd relaxation then even them out, and the same seed number always gives the same seeds, so a design stays put from one run to the next.

An affector is any shape whose nearness grades a pattern: a point, a curve, a surface or a solid, with a strength, a radius and a falloff. Near an affector the Poisson seeds come closer together and the cells shrink. A solid can count as a region, small cells all through it, or as a surface, small cells along its skin on both sides, which is how a part gets fine cells under its skin and coarse ones in its core.

Seeds graded by a curve and a point

The same affectors grade anything else through a field, read at any points and mapped onto the range you choose: one number a seed, which every structure takes in place of a single setting, as a cell's weight, a hole's opening, a window's size or a strut's radius. The structures take the numbers, not the affectors, so a field from a simulation or a spreadsheet works just as well.

Perforated faces​

A perforated panel is the Voronoi pattern most people have held: a grille, a screen, a lamp shade, a speaker cover. perforate makes each seed's cell smaller, rounds its corners with exact arcs and puts it back into the face as a hole. Scaled holes leave bars that are wide between large cells and thin between small ones; inset holes leave bars exactly twice the inset wide everywhere, an even lace whatever the cells' sizes. A hole that would come closer to the edge than a margin you set is left out whole rather than shrunk, so the panel keeps a clean border.

The result is one face with its holes, built without a boolean, so it extrudes into a plate, thickens, or becomes the blank of a sheet metal part.

A round grille whose Voronoi holes open toward the centre like a sunflower's head and shrink to pinpricks toward the solid rimA sheet metal vent panel: a perforated blank with even bars between its Voronoi holes, its four flanges bent down off its edges

On the left, a field opens the holes toward the centre like a sunflower's head and closes them toward the rim, which becomes the grille's solid border. On the right, the vent panel: holes inset for even bars of 3, kept 7 from the blank's edges so that every hole stays in flat sheet when its four flanges are bent down, and a sheet metal check confirms it is still a sheet of one thickness.

Frames, struts and foam​

A Voronoi diagram has edges, faces and cells, and each can carry material. All of these are built straight from the cells, and each takes values per seed, so a field can grade it.

  • Beams put a strut on every edge of the cells, round or prismatic, with a sphere at each node, in a face or in a box or convex solid: a strut lattice. Its report carries the lattice as plain data, nodes, struts and radii, to rebuild it in another program or export it as JSON.
  • Frames cut a window in every face between two cells, the open cage most people picture when they hear "Voronoi". Given a wall, each cell becomes one hollow solid, and neighbouring cells touch face to face without overlapping.
  • Closed-cell foam makes a solid into one solid with a sealed void in each cell and a skin you set all round, built without a boolean.
  • Open-cell foam opens windows between the voids, and through the solid's own faces when you ask, so the inside and the outside become one surface, as in a sponge.

Struts in space, frames and walls need a box or a convex solid of planar faces to grow in, where every shared piece is made once; the foam takes any solid.

A strut lattice in a cube: a round beam on every edge of the Voronoi cells, with a sphere at each nodeThree hexagonal prisms of Voronoi frames: flat frames with rounded windows, hollow walls scaled toward each cell's centre, and walls of one thickness
A block made into closed-cell foam and cut open to show its sealed voids, one in each Voronoi cellA block of open-cell foam, its voids joined to each other and to the outside through windows in its faces

The beams and flat frames come as a compound of separate pieces, one beam a strut, one sphere a node and one frame a face, which overlap where they meet. That is what a 3D printer needs: export the compound and print it, since slicers merge overlapping bodies into one.

Four pieces made for 3D printing​

The learn pages put the whole family to work on four pieces meant to be printed, each built from start to finish in one script, in Rete, Blockly and TypeScript. Each grades its pattern with a field: a regular grid of holes or struts is the same everywhere, while Voronoi cells can be small where you want detail and large where you do not, changing smoothly between.

A dragonfly-wing pendant, a lace of Voronoi holes graded small along its veins and edge, with a hole for a jump ringA lattice mount: Voronoi struts between a round load pad and a base plate with four bolt holes, thicker toward the pad and the plate
  • A dragonfly-wing pendant. Four curves fan out from the wing's root like its main veins, but they are never built into the pendant: they only grade the seeds, so the cells grow small along them. Every hole is inset by the same 0.2, so every bar is 0.4 wide, and where the cells are small the bars crowd together and read as veins, though no vein is drawn.
  • A lattice mount. Struts fill the space between a load pad and a bolted base plate. The cells are smallest under the pad, where the load comes in, and a field read at every seed thickens the struts toward the pad and the plate and keeps them slender in between.
An arm between two pin bosses, cut open to show its closed-cell foam core, fine under the skin and coarse in the middleA tapering hexagonal tea-light lantern whose Voronoi holes are small low down and open up toward the top
  • An arm with a graded foam core. Plant stems grade theirs, fine just under the surface and coarse in the middle, and so does this link between two pin joints: the arm itself, measured as a surface, draws small cells under its skin, while the cells at both joints are kept solid so the pins sit in solid material. The picture shows it cut open; the part to print is the whole arm with its pin holes drilled.
  • A tea-light lantern. Six panels taper upward, with small cells and wide bars beside the flame and large cells and thin bars at the top, where the light spills out. The panels, a base and a ring are thickened together into one solid.

Every piece is exact geometry, so it exports as STEP for a CAD program or as STL for a slicer.

Thickening a shell with exact mitres​

The lantern is made with another new function, bitbybit.occt.operations.thickenPlanarShell, which thickens a shell of planar faces into a solid without offsetting anything. Each face's plane moves by its thickness, each edge two faces share is cut by a mitre, and each hole, made of lines and circular arcs, becomes a straight tunnel through its face. Neighbours meet in exact joints whatever the angle between them, a face may hold hundreds of holes, and the result is built from planes and cylinders alone.

A close-up of the lantern's top: the ring and the perforated panels meeting in exact mitred corners, each hole a tunnel through its panelA star-shaped vase whose walls and floor were thickened from planar faces, meeting in mitres at every point and hollow of the star

The lantern's eight faces are thickened inward by 2.4 in one call, so its panels meet each other, the base and the ring in exact corners, with no posts and nothing overlapping, in a fraction of a second. Each face can take a thickness of its own, an open shell is thickened along or against its faces' normals with its free edges walled square, and a hole whose tunnel would cut a mitre is either refused, with the face and the hole named, or closed and reported. The star vase beside it is an open shell, a star of walls on a floor, thickened inward so its outside stays where it was drawn.

Where to use it​

Voronoi patterns suit anything that should be light, open or graded: lamps and lanterns, jewellery, architectural screens and facade panels, grilles and speaker covers, lightweight brackets and mounts, enclosures, packaging and cushioning, and parts that air should pass through. In a configurator, a new seed number gives each customer a pattern of their own.

Everything shown here is free and runs wherever Bitbybit runs, in the browser or on your own server. For smooth foam lattices grown inside a part, Bitbybit CAD Cloud adds a Pro algorithm of its own, which runs on our servers.

Try it​

Start with Voronoi patterns, which explains cells, seeds, weights and what is built from them, then read seeds and fields, perforated faces, cells in space and lattices, frames and foam. Made for 3D printing builds the four pieces step by step, and thick solids covers the planar thickening. Each example is there in Rete, Blockly and TypeScript. The renders in this post are made in Blender from the shapes those scripts build.

Want a Voronoi pattern on a product of your own? Reach out to us.