Lesson 3.10 · III Modelling
Rounding the edges of solids
What this is about: Lesson 3.9 rounds curves before they become surfaces. But many edges only appear when solids are put together: where a hole leaves a plate, where a boss stands on a plate, where two boxes form an L. This lesson rounds such edges afterwards, exactly, with the booleans from lesson 3.7. A ball rolling along the edge decides the rounding. What lies between the ball and the edge is taken away or filled in. The hard part is not the rounding itself, but that it only touches the faces.
What you should know first: lesson 3.7 (booleans),
lesson 3.9 (fillet, the rounding of a corner in the plane)
and lesson 3.6 (how intersections of surfaces are found).

export part
|> fillet_edges(_, upright, corner) // the four upright edges of the block
|> fillet_edges(_, (boss, 0, h), foot) // the boss's foot: a fillet
|> fillet_edges(_, (boss, 0, h + height), rim)
|> chamfer_edges(_, (hole, 0, h + height), bevel)
Which edges work, and how:
| Edge | Example | how the rounding is made | Section |
|---|---|---|---|
| straight, between flat faces | edge of a box | a cross-section, extruded: exact | 3 |
| round about an axis | rim of a hole, foot of a boss | a cross-section, revolved: exact | 3 |
| curved otherwise | two tubes as a tee, a slanted hole | the ball rolls, station by station | 6 |
| a run of edges without a kink | top edge of a box with round corners | the ball rolls along the whole run | 7 |
| straight edges with a kink, together | rim of a pocket, a picture frame | one tool, mitred | 8 |
1. Using it
fillet_edges(shape, at, r) rounds the edge nearest the
point at with radius r;
chamfer_edges(shape, at, d) cuts it off at a slant, d from
the edge on each face. at can also be a list of points:
then all these edges are rounded together, which makes
a difference at corners (section 8). An outer edge loses its corner, an
inner one gets a fillet.
Every curve where two faces of the solids meet is a candidate: the
solids' own edges (the edges of a box, the rims of a cylinder) and the
cuts of the booleans (the circle where a hole meets the top). The
nearest one is chosen. If a second one is almost as near, say at a
corner where three edges meet, fillet_edges names both
places instead of guessing. Only curves that really are edges of the
shape are candidates: own edges are split where other solids cut them,
and each piece is checked for points inside and outside around its
middle.
2. The principle: ball, tool, boolean
A ball of radius r rolls along the edge, touching both faces. What lies between the ball and the edge is too much at an outer edge and missing at an inner one. Cut across the edge, this becomes the task of lesson 3.9: two curves meeting in a corner, and a circle of radius r touching both.
This cross-section becomes a tool solid. Its outline
is the arc of the rounding, at each of its ends a short side standing
upright on the face and pointing away from the ball, and a back that
goes round the corner. At an outer edge the tool encloses the corner
with some air, and difference takes it away. At an inner
edge the sides point into the solid, and union fills the
fillet in. The rest of the tool lies in air or in the solid and changes
nothing there. So that this holds for thin material too (a plate under a
boss), the sides at an inner edge are only a seventh of r long.
A chamfer is simpler: its tool is a triangle across the edge whose long side cuts both faces at distance d from the edge.
3. Straight and round edges: exact
For two kinds of edges every cross-section looks the same:
- A straight edge between two flat faces (or between
a plane and a cylinder lying along the edge): the cross-section is
extruded along the edge (
extrude); the rounding is a cylinder. - A round edge between two faces revolved about its
axis (the rim of a hole, the foot of a boss): the cross-section
is revolved about the axis (
revolve); the rounding is a piece of a torus.
A boolean's cut is only accurate to about 10⁻⁴ mm (lesson 3.6); an axis computed from it would sit a little off. So the axis comes from one of the two faces, and the corner in the cross-section is found exactly from the two profiles.
Why touching is hard. The arc touches both faces tangentially along a whole line. The booleans, though, look for cuts, with Newton's method on S₁(u₁, v₁) = S₂(u₂, v₂). Where two faces only touch, their distance grows with the square of the distance from the line of contact; an error of 10⁻⁸ in the distance moves the point found by 10⁻⁴ across the line, and whether the search finds the line at all depends on the start points. Here it does not have to: the line of contact is known, because whoever builds the tool knows where it stands on the faces. The boolean gets this line as a ready-made cut, and where an edge of the solid crosses it, the split point is found as the crossing of two curves, not searched for on the tool's face. Everything after that runs as in any boolean.
4. Which side, which ends
In the cross-section each face runs on from the corner in two directions, but only one belongs to the solid; for the top of a plate that stops at a hole, the face itself does not even say so. So the question goes to the solid: a ray test (as in lesson 3.7) checks a little way along each direction whether just in front and just behind, one point is inside and one outside. Whether the edge is outer or inner is then told by a point on the bisector.
A straight edge ends somewhere. The tool of an outer edge runs on past the ends and only takes air away there. If the edge ends at a wall standing square to it (the rim of a pocket), the tool ends flush there; if the wall is slanted, there is a message. The tool of an inner edge always ends flush with the edge, or it would fill in air beyond.
5. How it is checked
Every rounding has a volume that can be worked out by hand:
- straight edge, length L: the corner loses (1 − π/4) · r² · L. That is the square r × r without the quarter circle in it, along the edge.
- round edge: the same area, revolved. By Pappus, the volume is area × the path of its centroid, 2π (R ± x̄) (1 − π/4) r². The centroid of the corner piece lies x̄ = (10 − 3π) / (12 − 3π) · r ≈ 0.223 r from the corner. For a hole (outer edge) it lies outside the hole's radius R, for the rim of a boss inside.
- chamfer: r² · L / 2 on a straight edge, π (R + d/3) · d² on a round one.
- mitre (section 8): at each corner the strips of the two roundings overlap in a square of side r. That is r³ (5/3 − π/2) more (outer corner) or less (inner corner) than the lengths say; for a chamfer d³/3.
Fuzzers build boxes, drilled plates, bosses, tees, slanted holes, pockets, notches and frames in any position, round or chamfer their edges and compare the volume with these formulas (for rolling balls with the cross-section integrated numerically). Nearly all cases are closed and agree to a few 10⁻⁴; the few others give a message that the handbook (chapters 8 and 14) names with a way round.
6. Curved edges

Where two tubes meet or a hole goes through a plate at a slant, the angle between the faces changes along the edge. Here the ball really has to roll.
Stations. At many places along the edge the ball is found on its own. The unknowns are the parameters (u, v) of the two points of contact, four numbers. Three equations say that from both points of contact, r along the normal, you reach the same centre: S_A + r · n_A = S_B + r · n_B. So the centre lies on both offset surfaces (lesson 3.8), and the ball's centre line is where they meet (lesson 3.6). The fourth equation puts the centre into the plane across the edge at this station. Newton solves it; the previous station gives the start.
Cross-sections and loft. Every station gives a cross-section of the tool; they all have the same form (the same knots), so that a loft (lesson 1.3) goes exactly through them. Between the stations the tool is approximate. Halfway between each two stations the ball is found exactly once more; if the loft is too far off, a station is added there.
Dipping instead of touching. Because the loft is
approximate, its line of contact does not lie exactly on the face and
cannot be passed on as a known cut. What boss does helps
here (lesson 3.9, section 6): the ball's centre lies r − r/100 from both
faces. The arc dips in by r/100 and cuts the faces at about 8°, a cut
the booleans find for sure. With r = 2 mm the rounding is 0.02 mm
off.
Back and ends. The back runs along the faces' tangents round the corner. Where a strongly curved face departs from its tangent, the back would dip into the shape before the edge; then it runs straight at every station to a point just beyond the edge. The tool of an outer edge runs on past its ends, along the edge's circle of curvature; that of an inner one is cut off at a flat end face.
Chamfers take the same way, only without dipping: at every station the two points where the chamfer cuts the faces lie exactly d from the edge.
7. Runs of edges

The top edge of a box whose upright edges are already rounded is made of pieces: straight lines between the top and the sides, and between them arcs between the top and the cylinders of the earlier roundings. They run into each other without a kink, and all of them share one face. Such pieces are chained into a run, and the ball rolls along it like a curved edge. The rim of a slot, of a U-shaped notch and the floor of a pocket with round corners come about the same way.
The tricky place is where the run passes from a side into an arc: three faces meet there, two of them only touching, and the computation for three faces (lesson 3.7) is nearly singular. So that point is found on the known line of contact, and first; other cuts near it take it over.
A run cannot be rounded more tightly than it bends: if the ball is larger than the earlier roundings, its centre would run backwards at the corner. Then the run goes mitred over these tight arcs (section 8): the straight pieces are extended to the sharp corners they would form without the earlier roundings. If only some arcs are too tight, the run is mitred over those and rolls round the others; the tool is then one face all round the run.

8. Mitres: straight edges rounded together

Where straight edges meet at a sharp corner, such as the rim of a pocket or the top edge of a box with sharp upright edges, there is no run. Round them one by one, and at the corner two tools of equal size cross at a right angle: the case of two equally thick cylinders crossing, which the booleans cannot do (lesson 3.7, section 4).
If the edges are rounded together
(fillet_edges(shape, [p1, p2, …], r)), one single tool is
made instead, like a picture frame. At each corner lies the
mitre plane, which halves the angle between the two
edges. Each cross-section is moved along its edge into this plane, and
the same curve must arrive there from both sides. A loft of degree 1
through these curves gives exactly the straight tool between two
corners, with a kink at the corners. Here, too, the arc dips in by
r/100, or at a box's corner three faces and the tool would touch in one
point.
9. Limits
- Ball corners. Where three rounded edges meet, a
piece of a sphere would have to join the three tools. Instead the corner
is mitred, or
fillet_edgesreports that the edge is only partly an edge of the shape. Ways round:rounded_boxandrounded_extrudebuild the shape with round corners from the start (lesson 3.9), or round the upright edges first and then the top edge as a run. - Mitres on slanted walls or between different cross-sections: the cross-sections do not arrive in the mitre plane as the same curve, and each edge is rounded on its own.
- A tight arc at the end of an open run: the second straight piece for the mitre is missing next to it.
- Inner curved edges ending at a curved face: the tool can only be cut off at a flat face.
- Rounding a rounding: the new edges of a tool are tangential and no longer edges.
- Sharp wedges. At an angle α the ball touches the
faces r / tan(α/2) from the edge; but the faces are only followed 4 r
and a thousandth of the part's size far. Below about 28° only small
roundings fit (the message says how small), for a part at the origin
none below about 22.6°; below about 10°
fillet_edgesno longer recognises the edge. If the wedge is extruded from an outline,filletrounds the corner in the outline first.
What to do in these cases is in the handbook, chapter 8.
Try it yourself
cargo run --release -p kf -- render examples/edges.kf -o out/edges.png
cargo run --release -p kf -- render examples/edges.kf -D foot=6 -o out/edges.stl
cargo run --release -p kf -- render examples/tee.kf -D branch=10 -o out/tee.png
- Point exactly at a corner of the block. What does
fillet_edgesreport? - Round the upright edges first, then one top edge of the block. What happens if you round only three of the upright edges, and what if the top rounding is larger than the upright ones?
- Work out the volume of
edges.kfby hand: block, boss, hole and the four kinds of rounding from section 5. - Build an L from two boxes and round the inner edge. How much volume is added?
- In
tee.kf, make the branch almost as thick as the main tube. How does the rounding change at the sides, and why?