Hi mathog,
On Fri, Oct 18, 2013 at 04:07:16PM -0700, mathog wrote:
I see it, but don't understand why:
Geom::cubicbezierpath_from_sbasis
generates so many beziers for an elliptical arc with a fit parameter of 0.1.
Because Geom::cubicbezierpath_from_sbasis is fitting the parameterisation rather than the geometric shape. That is, we think of a path as a pair of functions X(t), Y(t) with t in [0,1], but any function t(u) such that t([0,1]) = [0,1] gives another path X(t(u)), Y(t(u)) which is the same path. There is a best path approximation if we're allowed to change the parameterisation, and for circular arcs this has been worked out explicitly. This function, however, minimises |X(t) - Bezier(t)| over t, rather than |X(t) - Bezier(u)| over t,u.
There have been papers published on ways to do this efficiently in general (one search term is geometric interpolation). Nobody has implemented a competitive algorithm. I would recommend modifying the ellipse code to use the known approximation directly rather than going via sbasis (or equivalently, generating the approximation in sbasis form rather than using sin,cos in which case Geom::cubicbezierpath_from_sbasis should be the identity).
regards, njh