knotflow Lessons PDF ↓ Deutsch Handbook Modeller ↗ Source

Lesson 3.15 · III Modelling

What research knows about intersections

What it's about: Lesson 3.6 shows how knotflow finds the curve where two surfaces intersect, and Lesson 3.7 shows how Booleans are made from it. Both honestly state their limits at the end: tiny loops, touches, tolerances that "hold in one's head". Research has worked on exactly these points for forty years. This lesson presents six ideas from research papers that knotflow intends to adopt, and three that it deliberately does not. Formulas are only provided where they are helpful. Each section states where knotflow stands today.

Prerequisite: Lesson 3.6 (start points, tracing, touching). The sections are independent of each other; you can jump around.

Status: The methods in this lesson are planned in knotflow, not yet built. If one is implemented, its section will move to the lesson describing that method (3.6, 3.7, or 3.8).

1. What it's actually about: the first point

Tracing an intersection curve (Lesson 3.6, Section 3) is reliable: if you have one point on the curve, you can find the rest. The difficult part is the first point on each branch. To handle this, knotflow breaks both surfaces into coarse triangles and looks for where triangles come close to each other. It finds an astonishing amount: a torus just below a plane (distance 0.00001 mm) yields both rings; a sphere whose cap rises above a plane by 0.000001 mm yields its tiny circle.

However, there is no proof that nothing is missing. The method is called subdivision in the literature: decompose, compare coarsely, refine. It fails exactly where a loop is smaller than the deviation of the triangles from the surface, or where the surfaces almost touch along an entire line. A comparison in a recent article (Yang & Jia 2026) sent 1000 pairs of surfaces through common CAD kernels: the best found the correct shape of the intersection curves in 99.2 %, a widespread free kernel in 90.6 % of cases. What was missing was almost always small loops and touching points.

2. Finding small loops across the distance landscape

Idea (Yang & Jia 2026): Instead of searching for places where the surfaces meet, search for places where the distance between them has a peak or a valley.

Imagine the first surface as a map with coordinates (u, v). For every point, record how far away the second surface is, with a sign: positive on one side, negative on the other. This creates a landscape φ(u, v). The intersection curve is the contour line 0 of this landscape, the "coastline."

The distance landscape over the first surface: grey contour lines, violet the contour line 0 (the intersection curve, here a small loop), arrows of the gradient at the points of a coarse grid, coloured by quadrant. The peak is in the pink field.

Now the crucial thought: A closed coastline always encloses a peak or a valley. An island has a highest point, a lake a lowest. Whoever finds all peaks and valleys finds every loop, no matter how small. At a peak, the landscape is flat: the gradient (the arrow pointing uphill) is zero. Such places are called critical points. Geometrically, these are places where the two surface normals are parallel.

How do you find critical points without scanning the landscape finely everywhere? Via the winding number:

  1. Place a coarse grid over the map and calculate the gradient at each grid point. This is cheap.
  2. Only remember which quadrant the arrow points to: top right (1), top left (2), bottom left (3), or bottom right (4).
  3. For each grid cell, traverse the four corners counter-clockwise. If the arrow rotates all the way around (1, 2, 3, 4), the winding number is +1. If it just wobbles back and forth, it is 0.
  4. A cell with a winding number not equal to 0 must contain a critical point. This is a theorem of topology, not a rule of thumb.

Left: The gradient rotates once around the corners (quadrants 3, 4, 1, 2), the winding number is +1, a critical point lies in the cell. Right: It only wobbles (1, 1, 2, 1), the winding number is 0. Far right are the colours of the four quadrants.

In such a cell, Newton's method (Lesson 3.5) finds the critical point precisely. If it lies at height 0, the surfaces touch there in a point. If it lies above or below, draw two lines from it across the surface and intersect them with the other surface. This yields start points on the loop, and tracing from Lesson 3.6 takes over.

Two subtleties:

A neighbouring article from the same group (Yang et al. 2025) provides a guaranteed bound for how far the coarse triangles deviate from the surface at most. Currently, knotflow uses a flat five-hundredth of the surface's size for this. With the bound, it would know for each triangle how close "close enough" is.

For knotflow: The search for start points gets the winding number as a second method alongside the coarse triangles. The procedure breaks down into small, individually verifiable steps and only needs building blocks that already exist (nearest point on a surface, Newton with four unknowns). The authors have filed a patent application on the winding-number search (see Literature).

3. What lies at the end of a branch

Lesson 3.6 traces a curve along t = n₁ × n₂. Where the normals are parallel, t is zero, and tracing stops. Today, knotflow guesses what is there: a branch shorter than ten times the tolerance counts as a touching point. This usually works well. Two spheres with radius 10 that overlap by 0.0000001 mm correctly yield a tiny ring. At 0.00000001 mm they still overlap, in a circle of about 0.0003 mm radius, but knotflow reports "the surfaces touch along a line". This is incorrect: they do not touch along a line.

Idea (after Ye & Maekawa 1999, summarised in the overview by Patrikalakis et al.): Instead of guessing, look more closely at the neighbourhood of the point. Where the normals are parallel, both surfaces look like curved shells touching at the point. Their difference in the next approximation is a simple second-degree polynomial in the two directions x and y:

b₁₁·x² + 2·b₁₂·x·y + b₂₂·y²

The numbers b come from the curvature of both surfaces. Experts call this the second fundamental form, which is curvature written as a formula. Where the polynomial is zero, the intersection curve lies. And a single value, the discriminant d = b₁₂² − b₁₁·b₂₂, tells which of three cases applies. It is the same calculation as the question of whether a quadratic equation has two, one, or no solutions:

Three cases where the normals are parallel. Grey are the contour lines of the difference, violet where it is zero. Left (d < 0): only the point itself, a touching point. Middle (d > 0): two lines intersect, four branches go out from the point. Right (d = 0): a double line, the surfaces touch along a curve.

The same curvature provides a second benefit: the step size. Lesson 3.6 halves the step until the segment fits, and then lengthens it again. If the curvature κ of the intersection curve is known, the correct length is immediately clear: approximately √(8·tolerance/κ). On a circular arc with radius 10 mm and a tolerance of 0.0001 mm, this is about 0.09 mm.

For knotflow: replaces the rule "shorter than ten times the tolerance" with a calculation, and tracing goes through intersections instead of ending at them.

4. When are two points "the same"?

Every Boolean operation constantly asks: Is this corner the same as that one? Does this point lie on that edge? knotflow answers this today at many places with its own factors: four times the tolerance here, ten times there, one millionth of the size at a third place. Every factor is correct for the examples it was made for.

Idea (Jackson 1995): Every part carries its own tolerance. A corner is a small sphere, an edge a thin tube, a face a thin layer. The tolerance measures how precisely the part was actually calculated. A corner where three faces almost meet tangentially is less certain than one where they meet at a right angle, and gets a larger sphere. A comparison then always checks against the sum of the two involved tolerances.

Top: Corners as spheres, the edge as a tube, the face as a thin layer. Bottom: Two calculated corners whose spheres overlap are one corner (green); two that are further apart than the sum of their tolerances are two (red).

In addition, there are three rules from Jackson and two other articles (Huang et al. 2023, Benouamer et al. 1993, Tsuzuki & Shimada 2003):

Deliberately not adopted: Jackson lets tolerances grow. If something does not fit, the sphere gets larger until it fits, and corners are merged. This contradicts the principle of knotflow to build exactly (Lesson 1.4). A violation should be a finding, not a repair.

For knotflow: a single function for all "the same?" questions, with measured tolerances instead of scattered factors. This is a large rebuild, and its scope will be settled first.

5. Does a surface cut itself?

An offset surface (Lesson 3.8) can run into itself if the distance is greater than the radius of curvature. A loft or sweep can swing beyond its end cross section. knotflow only checks this today for the offset surface, using a mesh and a tolerance. Small, almost tangential self-intersections slip through. It does not check lofts and sweeps at all.

Idea (Li et al. 2025): a cheap certificate, i.e., a proof that only says yes when it is certainly correct. One takes the normal in the middle of the surface as a reference and asks: Does every other normal of the surface point into the same half of space? If yes, the surface cannot cut itself. It would have to fold over, and in doing so, a normal would reverse.

Left: All normals point into the same half as the middle one (green), the curve cannot intersect itself. Right: At the ends, the normals tilt beyond 90° (red), no certificate, the surface is split and each half is checked anew.

The beauty of this: The question "does every normal point into the same half?" can be answered without scanning. The dot product of the normal and the reference is itself a spline function. Its coefficients follow directly from the control points of the surface. If all are ≥ 0, the whole function is ≥ 0: A spline function only mixes its coefficients (like de Casteljau in Lesson 1.2) and therefore always stays between the smallest and the largest. If a coefficient is negative, the surface is split and the parts are checked. Only where this no longer helps is precise calculation performed.

For knotflow: a fast pre-test before today's check of the offset surface and for the first time a check for loft and sweep. Self-intersections found are reported, not silently trimmed.

6. Crossing or just touching, in the plane

Even in 2D, in outlines for extrude and regions, curves intersect. There is a trap there that knotflow probably has, judging from its code, though no example has shown it yet: If two curves run almost parallel at an intersection point, the place is discarded as a "touch". But there are places where they run parallel and still cross.

Left: A curve with an inflection point (y = x³) runs parallel to the line and still crosses it, its ends lie on different sides (− and +). Right: A parabola (y = x²) only touches the line, both ends lie on the same side.

Idea (Yap 2006): Divide each curve into elementary pieces: each is only convex or only concave, without an inflection point. Inflection points can be recognised at the control points. For two such pieces, a sign then decides: If the ends of one piece lie on different sides of the other, they cross. If they lie on the same side, they touch at most. An angle is not used as a bound for this.

For knotflow: first a test case that shows whether the trap really springs. Only after that is the procedure built.

7. An independent cross-check

How do you check Booleans? Lesson 3.7 compares volumes: A ∪ B and A ∩ B together must be as large as A and B together. This finds a lot, but not everything. If a piece is missing in one place and there is one too many in another, the errors cancel out in the balance.

Idea (EMBER, Trettner et al. 2022, and as a predecessor Benouamer et al. 1993): Booleans on triangle meshes can be computed exactly, without rounding errors, using integers and fractions. This is slow and unsuitable for output because the curve of intersection then consists of triangle edges instead of the real curve. But it is suitable as a referee: You decompose both inputs into triangles, compute the Boolean exactly, and compare the result piece by piece with that of knotflow. Any deviation above the tolerance of the decomposition is a finding.

For knotflow: an additional check in the fuzzer, offline, with a free library. Not as a replacement in the program.

8. What knotflow deliberately does not adopt

9. What we learn from this

All six ideas have the same pattern: A general method replaces a rule of thumb. "Branch shorter than ten times the tolerance" becomes the discriminant, "four times the tolerance" becomes the sum of two measured tolerances, "angle smaller than one millionth" becomes a sign. The rules of thumb were not stupid. Each was correct for the cases that one had in mind while writing it, as Lesson 3.6 says at the end. The methods from research also hold for cases that no one thought of. That is why reading is worth it.

Literature

The articles are retold in our own words; the pictures of this lesson are drawn for it.

The authors' research group has filed patent applications on several methods in this lesson: on the winding-number search from section 2 (CN 122289376 A), on a Boolean with a mesh and exact surfaces as in section 8 (CN 121033327 A) and on surface intersection (EP 4752778 A1). Anyone who rebuilds one of these methods should read the claims first. This lesson describes ideas and is not legal advice.

Try it yourself

mkdir -p out
python3 tools/research-figures.py out      # the pictures of this lesson
  1. Two balls that barely overlap: compute len(intersect(sphere(10), sphere(10) |> move(x: 20 - d))) for d = 0.1, 0.001, 0.00001 and 0.00000001. How large is the ring each time (r ≈ √(10·d))? From when on is it smaller than the tolerance of 0.0001 mm, and what should intersect say then?
  2. For a landscape with a peak and a saddle side by side, draw the arrows at the corners of a cell that holds both. Why is the winding number 0?
  3. For b₁₁ = 1, b₁₂ = 0, b₂₂ = −1, d > 0. In which directions do the four branches run? And for b₁₁ = 1, b₁₂ = 1, b₂₂ = 1?
  4. To think about: why is the certificate of section 5 only sufficient? Find a surface that does not cut itself but whose normals still do not all point into the same half.