I am trying to correct Mathics' ability to draw Bézier curves properly in Asymptote, and I have a hard time understanding how to translate Mathematica's Specification into Asymptote. I haven't found an easy-to-understand description or tutorial of how to draw Bézier Curves in Asymptote.
So let me try show what I want to be able to do with a basic example:
Mathematica (actually, Mathics):
Graphics[BezierCurve[{{0,0}, {1,1}, {2, -1}, {3,0}}]]
Incorrect translation of first example above:
usepackage("amsmath");
size(5.8333cm, 5.8333cm);
// BezierCurveBox
draw(0,.0.0), rgb(0, 0, 0)+linewidth(0.66667));
draw((0.,0.)..controls(155.56,213.89) and
(194.44,194.44)..(233.33,116.67),
rgb(0, 0, 0)+linewidth(0.66667));
Above, I have given how Mathics currently converts this. One of the bugs seen above seems to have to do with translating control-point coordinates to center the figure in overall image window, while not translating some of the non-control points. And there is what looks like a stray point drawn at the beginning.
I leave this in. But in giving a solution, feel free to totally disregard this and describe something from scratch that has the same shape as what is intended.
So how do I fix this, and how do I think about doing correct translations like the Mathematica-to-Asymptote example above?
Follow on:
I have implemented the accepted answer and that works for the more simplified example I gave, but when I extend the number of points to
pts = {{0, 0}, {1, 1}, {2, -1}, {3, 0}, {5, 2}, {6, -1}, {7, 3}};
it looks like the accepted answer differs from what Mathematica does here.
It looks like the output from the accepted answer:
is more influenced by point 4 than what Mathematica does. And I also note that there is a SplineDegree:
With SplineDegree->d, BezierCurve with d+1 control points yields a simple degree-d Bézier curve. With fewer control points, a lower-degree curve is generated. With more control points, a composite Bézier curve is generated.
As found in the comment by @WillieWong what is going on is that Mathematica draws curves three points at a time which is also seems to be how SVG handles lists of points.
How to I handle curves of higher degree?
Lastly, I should mention that the next release of Mathics will incorporate the improvements due to the information and help found here.




If it helps, any point(s) can be adjusted accordingly for the original or translated coordinated space. I am more interested having something having the right shape rather than where it is located in the graph.
– rocky Aug 11 '21 at 11:57