knotflow Handbook Deutsch Lessons Modeller ↗ Source

Chapter 12

Organic forms

Branches growing into one another, bones, a body as if kneaded from clay: such forms have no edges but flowing transitions. Surfaces from control points (chapter 5) and Boolean operations (chapter 7) only get there with a lot of effort. knotflow has a second way of describing shapes for them: implicitly.

The idea in two sentences

An implicit shape is a rule that says for every point in space how far it is from the surface: negative inside, positive outside. Two such shapes can be merged so that where they come close, a fillet grows, a soft rounding in the corner between them.

The result is a mesh, a net of triangles, not an exact solid of faces. For the printer that is just as good; what else it means is listed under the limits below.

Melting balls and rods

The same four parts, on the left without fillets, on the right with

param fillet = 4   in 0..10  "size of the fillets [mm]"
param voxel  = 0.5 in 0.2..2 "grid size [mm]"

let parts = [ball((0, 0, 12), 12),
             ball((0, 0, 30), 8),
             rod((0, 0, 16), (20, 0, 28), 2.5, r_end: 1.5),
             rod((0, 0, 16), (-20, 0, 28), 2.5, r_end: 1.5)]

export blend(parts, k: fillet) |> isosurface(voxel: voxel) |> simplify color "sage"

Line by line:

Choosing the grid size

voxel decides how fine the result is and how long it takes. Halve the grid size, and it takes about five times as long. Rules of thumb:

Groups: hard inside, soft between

Each element of the list for blend is a group. A group can itself be a list; its parts are joined hard, without a fillet. The rounding only grows between groups:

let arm  = [rod((0, 0, 0), (10, 0, 10), 2), rod((10, 0, 10), (25, 0, 12), 2)]
let body = [ball((0, 0, 0), 8)]

export blend([arm, body], k: 3) |> isosurface(voxel: 0.4)

You need this when a strand is made of many short rods: if each piece melted softly into the next, every seam would get a small bulge.

simplify: fewer triangles

simplify(mesh, tol:) removes triangles as long as the surface stays within tol mm (default 0.02) of the original: many in flat areas, few where it curves strongly. Closed solids stay closed. In the browser the Triangles checkbox shows where triangles were merged.

Fields: shapes in the plane

For flat parts the same principle exists in 2D, with fields: a grid with one number per cell, like a picture.

Two circles, melted softly, as a plate

param k = 10 in 0.5..20 "size of the transition [mm]"

let g = grid((-40, -30), (40, 30), 0.5)

// smooth minimum of two distance fields: merges two shapes with a rounding of size k
fn smin(a, b, k) = min(a, b) - h * h * k / 4
  where h = max(k - abs(a - b), 0) / k

let left  = sdf(circle(15) |> move(x: -15), g)
let right = sdf(circle(10) |> move(x: 14), g)

export plate(-smin(left, right, k), level: 0, thickness: 3) |> simplify

More tools for fields: step(x) (1 where x > 0, else 0), blur(field, r) (soften), xs(g)/ys(g) (the coordinates of every cell), mean. A picture from a PNG file is a field too (chapter 11).

Letting it carry: statics and finite elements

Organic shapes often look the way they do because they grew: where much load flows there is material, where there is none it is missing. knotflow can compute this. Statics asks which forces act in a structure when it is loaded. From that follows how thick each part must be.

A truss, its rods thick and thin by their load

param span  = 80  in 40..160 "span [mm]"
param panes = 6   in 2..12   "panels"
param rise  = 14  in 5..40   "height [mm]"

let w      = span / panes
let bottom = [(w * i, 0, 0) | i <- range(panes + 1)]
let top    = [(w * (i + 0.5), 0, rise) | i <- range(panes)]
let nodes  = bottom ++ top
let n      = panes + 1
let bars   = [(i, i + 1) | i <- range(panes)] ++ [(n + i, n + i + 1) | i <- range(panes - 1)]
          ++ [(i, n + i) | i <- range(panes)] ++ [(i + 1, n + i) | i <- range(panes)]

let sized = frame_sizing(nodes, bars, [0, panes], (0, 0, -1), r_min: 0.6, r_max: 2.4)
let rods  = [rod(nodes[i], nodes[j], sized.radii[k]) | (k, (i, j)) <- enumerate(bars)]

export blend(rods, k: 1.5) |> isosurface(voxel: 0.4) |> simplify color "sage"

For flat parts the same exists with fields: analyze_plane(density, shape, supports, cases) computes with finite elements. The area is divided into small cells, each cell follows a simple rule for how it deforms under force, and all together give a large system of equations. What comes out is the strain energy per cell: high where the material works, low where it is only carried along. The example bone lets a bone grow with it: material is added where the energy is high and disappears where it is low.

voronoi_sphere(points) gives matching nets: the points divide a sphere into Voronoi cells, each cell holding everything that is closest to its point. The cells' edges are the rods, their corners the nodes. The example voronoi_sphere sizes them with frame_sizing and melts them as above.

How the computations work inside: lesson 3.13 (finite elements, bone) and lesson 3.14 (truss, Voronoi).

Limits

These examples show what the building blocks can do. They are larger than the models above; read them from the bottom up, starting at the export.

Example Technique
fork three rods melted into a forked branch, with and without simplify
tree_roof tree columns, branching recursively, each crown one blend
voronoi_sphere several Voronoi nets on a sphere, the rods thick and thin after a structural analysis, melted at the nodes
romanesco self-similarity without implicit shapes: cones of cones of cones, on a spiral
bone a thigh bone in section that grows by a remodelling rule: fields and finite elements
facade no implicit shape, but grown parametrically: the fins of a facade opening towards a point (frame_on, place)

How implicit shapes are cut into triangles and what simplify does is explained in lesson 3.12, the bone in lesson 3.13 and the tree supports, Voronoi spheres, Romanesco and facade in the gallery (lesson 3.14).