Smoothly closed cubic path

Provide n+2 coordinate pairs, with n a not negative integer, all separated with comma or whitespace. Provide n+2 Control points. The first and the second belong to the first path segment. The first control points of the other segments are determined automatically with the command S. The path is closed automatically using the last and the initial point and control point.
To get a path in the visible range, points and control points should be in the range -100 to 100.
For wrong inputs the data are either reduced to a valid set or they are replaced with a minimal set with two points.


Path conversion

This can help to apply the method to affine and quadratic segments as well:
Using the usual parametrisations of Bézier curves, one can convert affine and quadratic segments into cubic segments with these formulas:

Conversion L to Q or C with i, f initial and final point of the segment:
M i L f = M i Q (i+f)/2, f = M i C (2i+f)/3, (i+2f)/3 f

Conversion Q to C (p control point):
M i Q p, f = M i C (2p+i)/3, (2p+f)/3, f

Provide the points as coordinate pairs. If p is empty, an affine segment is assumed, else a quadratic. To get a completely visible result as graphical output, point coordinates should be in the range -100 to 100, the control point can be slightly outside.

Point i
Point f
Point p

Comparison between simple interpolation methods

If one has a set of N points of a curve, one can approximate smooth curves with cubic splines. If the deriatives are given as well, the approximation is ususally the best. If this is not available, one can try to approximate the deriatives using the previous and following data points. Something like this should have been used already before Leibniz and Newton, therefore it is surprising, that this method is sometimes named after two persons in the last century (Catmull and Rom). However the accuracy of this method is pretty low. But a change of a data point has therefore only consequences for the curve to the previous and following point. If two consecutive points before and two after a point are used to approximate the derivative, the approximation is already much better and only these five points contribute to the derivative.

As an example a try to approximate a circle from five points:
Compare circle approximations with the original circle and given data points

Approximate an elliptic arc

The following script provides a comparison between an ellipse and elliptic arc (half ellipse) approximation with given derivatives and with numerically approximated derivatives (two consecutive points before and two after a point, specific rules with lower accuracy at the ending)

Number of points (five or more)
Contrast (0 to 1; 0 circle, 1 line)
Orientation angle of main axis from x-axis (in degree)
Start angle of arc from main axis (in degree)