_____

Splines

In general, if you want to draw a smooth line connecting or approximating data points, one way to do it is using splines.

There is a lot of information about splines on the Internet, so I will not go into details here, but only point to some interesting pages, and some code I wrote myself.

libgsl

The Gnu Scientific Library contains some functions to compute splines.

Centripetal Catmull–Rom spline

With a normal spline, the x-values of the data points must be ascending. When you have to deal with not ascending x-values, but in stead a random series of x-y values which represent a bending curve, you can use a Centripetal Catmull-Rom spline.

Some code examples are given in the Wikipedia page, but a simple C-code is missing. Here you find a C-code, derived from the Python code on the Wikipedia page. The script 'doit' compiles and runs the example and calls gnuplot to visualize the result:

catmull_rom example