Table Of Links
2 FLATTENING AND ARC APPROXIMATION OF CURVES
3 EULER SPIRALS AND THEIR PARALLEL CURVES
5 ERROR METRICS FOR APPROXIMATION BY ARCS
7 CONVERSION FROM CUBIC BΓZIERS TO EULER SPIRALS
CONCLUSIONS, FUTURE WORK AND REFERENCES
FLATTENING AND ARC APPROXIMATION OF CURVES
The core problem in stroke expansion is approximating the desired curve by segments of some other curve, usually a simpler one. These segments must be within an error tolerance of the source curve, and ideally close to a minimal number of them. We consider a number of source-to-target pairs, most importantly cubic BΓ©ziers to Euler spirals, and Euler spiral parallel curves to either lines or arcs.

There are generally three approaches to such curve approximation. The most straightforward but also least efficient is βcut then measure,β usually combined with adaptive subdivision. In this technique, a candidate approximate curve is produced, then the error is measured against the source curve, usually by sampling a number of points along both curves and determining a maximum error (or perhaps some other error norm). If the error is within tolerance, the approximation is accepted.
Otherwise, the curve is subdivided (usually at π‘ = 0.5) and each half is recursively approximated. A substantial fraction of all curve approximation methods in the literature are of this form, including Nehab [2020]. The main disadvantage is the cost of computing the error metric. Another risk is underestimating the error due to inadequate sampling; this is a particular problem when the source curve contains a cusp. The next approach is similar, but uses an error metric to estimate the error.
Ideally such a metric is a closed-form computation rather than requiring iteration. A good error metric is conservative, yet tight, in that it never underestimates the error (which would allow results exceeding the error bound to slip through), and does not significantly overestimate the error, which would result in more subdivision than optimal. By far the most efficient approach is an invertible error metric.
In this approach, the error metric has an analytic inverse, or at least a good numerical approximation. Because the metric is invertible, it can predict the number of subdivisions needed, as well as the parameter value for each subdivision. If the error metric is accurate, then approximation is near-optimal.
One example of an invertible error metric is angle step, used in polar stroking (Kilgard [2020b]); the number of subdivisions is the total angle subsumed by the curve divided by the angle step size, and the parameter value for each subdivision is the result of solving for a tangent direction. Another widely used invertible error metric is Wangβs formula (Goldman [2003], Section 5.6.3), which gives a bound on the flattening error based on the second derivative of the curve.
This metric is conservative but works well in practice; among other applications, it is used in Skia for path flattening. The chief limitation of Wangβs method is that it computes a subdivision bound for a BΓ©zier curve without accounting for the displacement of the parallel curve due to stroking. When applied naively to generation of parallel curves, it can undershoot substantially, especially near cusps.
2.1 Error metrics for flattening
The distance between a circular arc segment of length π and its chord, with angle between arc and chord of π (see Figure 3), is exactly (1βcos π) π 2π . The curvature is π = 2π π (equivalently, π = π π 2 ), and this remains constant even as the arc is subdivided. Rewriting, π = (1 β cos π π 2 ) 1 π . From this, we can derive a precise, invertible error metric. Subdividing the arc into π segments, the distance error for each segment is 1 π (1 β cos π π 2π ). Solving for π, we get:
π = π π
2 cosβ1 (1 β ππ
)
To flatten a finite arc, round up π to the nearest integer. This will cause the error to decrease, so will still be within the error bounds. Note that the number of subdivisions is proportional to the arc length. Another way of stating this relationship is that the subdivision density, the number of subdivisions per unit of arc length, is constant. The error metric for flattening an arc is exact. It always yields the minimum number of subdivisions needed to flatten the curve, and the flattening error is the least possible given that number of subdivisions.
For general curves, an exact error bound is not feasible, and we resort to an approximation. Again the circular arc provides a good example. Applying the small angle approximation cos π β 1 βπ 2 /2, the approximate distance error is π = π π 2 8π 2 , and solving for π we get π = π βοΈ π 8π . Note that this estimate is conservative, in that it will always request more subdivision and thus produce a lower error than the exact metric.
We are of course concerned with the flattening of more general curves (ultimately the parallel curve of a cubic BΓ©zier), not simply circular arcs, so the curvature is not constant. An obvious approach to try would be to use the maximum error. This would be conservative with respect to error tolerance, but also generate too much subdivision when the curve has a small region of high curvature. In the limit, the curve can contain a cusp of infinite curvature, which would entail infinite subdivision.
Similarly, sampling the curvature at a single point can either underestimate or overestimate the error. The ideal approach would be a form of average curvature that is tractable to compute, and accurately predicts the flattening error. To that end, we propose the following error metric to estimate the maximum distance between an arbitrary curve of length π Λ and its chord.
π β 1 8 β« π Λ 0 βοΈ |π
(π )|ππ !2
This formula is the same as the approximate error metric for circular arcs, except that instead of a constant curvature value, a norm-like average with an exponent of 1/2 is used (it is not considered a true norm because the triangle inequality does not hold). This particular formulation has two strong advantages. First, it has been empirically validated to accurately predict the distance between chord and curve for a variety of curves.
In particular, we believe that when curvature is monotonic, it is a tight bound both above and below (and later we will see that in our algorithm it is always evaluated on curve segments with such monotonic curvature). Second, this formula lends itself to invertible error metrics. This formula also has a meaningful interpretation: the quantity under the integral sign is the subdivision density, and represents the number of subdivisions per unit length of an optimal flattening as the error tolerance approaches zero. In particular, the number of subdivisions is:
π = β« π Λ 0 βοΈ |π
(π )|ππ ! βοΈ 1 8οΏ½

In addition, if the function represented by the integral is invertible, then the corresponding error metric is invertible. Evaluate the function to determine the number of subdivision points, then evenly divide the result, using the inverse of the function to map these values back into parameter values for the source curve being approximated.
2.2 Error metrics for flattening Euler spirals
We choose Euler spiral segments for our intermediate curve representation precisely because their simple formulation in terms of curvature (CesΓ ro equation) results in similarly simple subdivision density integrals. An Euler spiral segment is defined by π (π ) = ππ + π, or alternatively π (π ) = π(π β π 0), where π 0 = βπ/π is the location of the inflection point.
Applying the above error metric, the subdivision density is simply βοΈ |π(π β π 0)|. The integral is 2 3 β π(π βπ 0) 1.5 , which is readily invertible. An immediate consequence is that flattening an Euler spiral by choosing subdivision points π π = π Β· π 2 3 produces a near-optimal flattening, as visualized in Figure 4.
Authors:
This paper is
