# 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.

* [Splines that go through each data point](https://www.gnu.org/software/gsl/doc/html/interp.html#sec-interpolation)<br>
I like the the Steffen method, because this prevents overshoots.

* [Splines that approximate the given datapoints](https://www.gnu.org/software/gsl/doc/html/bspline.html)

## 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](https://en.wikipedia.org/wiki/Centripetal_Catmull%E2%80%93Rom_spline).

Some code examples are given in the Wikipedia page, but a simple C-code is missing. 
[Here](YYYdZZZ/splines/catmull_rom.zip)
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](YYYdZZZ/splines/catmull_rom.png)
