pcb-rnd knowledge pool


Planning curve support

curves by Tibor 'Igor2' Palinkas on 2018-05-05

Tags: developer, curve, spline, bezier

node source



Abstract: Planning curve support. Describe objectives and enumerate possibilities.


1. Objectives: what problem we are trying to solve

The only curve pcb-rnd supports is arc. We have full support for circular arcs and partial support for elliptical arcs. Implementing the missing code for elliptical arcs is rather difficult and the calculations are not looking efficient either, CPU-usage-wise.

The objective of this node is to research whether switching from arcs to another kind of curve can solve this problem. If such a curve algorithm is found, a later version of pcb-rnd would have these features:

What we expect from a suitable curve algorithm:

The simpler approach is to have one curve object only the minimal set of control points and let the user combine multiple curves for a longer trace. This is how we do lines (there are no polylines). However, this wouldn't make it easy to guarantee continuity on object boundaries, which is one of the important extras curves could add.

We may need to have a multi-segment curve, that is a "polyline" kind of object with many control points. This would guarantee smoothness but would complicate calculations and would also make them more expensive because of the large bboxes.

2. non-objectives: what problem we are NOT trying to solve

We do not have to introduce curves - while they are useful in some rare cases, they are not essential features. Thus curves will not happen as an addition to the model, just for the sake of having curves. Curves can happen as an arc replacement in the model, if the resulting new model is not much more complicated than the arc based model.

3. Candidates

Cubic Bezier

Pros: intuitive editing, simple rendering

Cons: poor arc approximation: 0.027253% or 0.019608% error

Many formats (ps, svg, ttf (quadratic!)) approximate arcs with Bezier curves and live with the error. Using 2 Bezier curves per quadrant may reduce error to 4ppm but that works only if the curve object is multi-segment . However, even the above poor arc approximation works only if a Bezier is a quadrant, approximating a full circle wouldn't be possible without multi-segment curves.

Bezier intersection.


Pros: relatively intuitive rendering, good arc approximation

Cons: TODO

spline, B-spline