I spent a while today casting around for a simple, fast and just-good-enough cubic interpolation algorithm to use in the GeoTools library where it is to serve as a 'filter function' that can be used when rendering maps.

The ACM digitial library has a mind-boggling collection of references on interpolation methods, most of which were fascinating but also over the top for this application.

In the end I put together the following code based on a Wikipedia article about cubic Hermite splines. Here it is...

/**

* Cubic hermite spline interpolation. This is adapted from the description of the

* algorithm at: http://en.wikipedia.org/wiki/Cubic_Hermite_spline.

* Tangent caculations are done with simple finite differencing in the interests

* of speed.

* <p>

* The input arrays xi and yi contain the coordinates of four interpolation

* points defining three segments with the middle segment containing the point

* for which we seek an interpolated value.

*

* @param x x ordinate of the po…

The ACM digitial library has a mind-boggling collection of references on interpolation methods, most of which were fascinating but also over the top for this application.

In the end I put together the following code based on a Wikipedia article about cubic Hermite splines. Here it is...

/**

* Cubic hermite spline interpolation. This is adapted from the description of the

* algorithm at: http://en.wikipedia.org/wiki/Cubic_Hermite_spline.

* Tangent caculations are done with simple finite differencing in the interests

* of speed.

* <p>

* The input arrays xi and yi contain the coordinates of four interpolation

* points defining three segments with the middle segment containing the point

* for which we seek an interpolated value.

*

* @param x x ordinate of the po…