How to create a Cubic Hermite Spline interpolation equation?

609 Views Asked by At

I am developing a program for which I need to smoothly interpolate between some control points.

Here is an example of what I need. Ie. In this gif, the knob is crossfading between no interpolation at 0 position, linear interpolation at 1, and smooth/cubic interpolation at 2 position. I need that cubic type of interpolation shown at position 2:

Interpolation

So let's say I have a co-ordinate grid of (0,0) to (1,1) with a minimum of two control points - one at $(0,y)$ and one at $(1,y)$, plus another 0-3 points in between at $0<x<1$.

I want an equation for a smooth line connecting these points like demonstrated in the graphic posted at position 2.

I believe a Cubic Hermite spline is the correct approach, and for example, I see on Wikipedia a Finite Difference curve seems correct graphically:

https://en.wikipedia.org/wiki/Cubic_Hermite_spline Finite Difference Spline

However, I do not understand the math they suggest. What is $mk$, $pk$, $tk$ in that equation and how would I work out an equation based on my co-ordinate points in my application?

1

There are 1 best solutions below

0
On

A cubic Hermite spline is determined by a set of ordered points, first derivatives at these points and paramaters assigned to each point. So, $p_k$, $m_k$ and $t_k$ simply means the $k$-th point, the first derivative at this point and the paramater assigned to this point.

Since you only have the data for $p_k$, you will first decide $t_k$ using either chord length parametrization or centriperal parametrization. These are the two most commonly used parametrization methods. After having $t_k$, then you can decide $m_k$ using various methods shown in the Wiki page for Cubic Hermite Spline. Once you have $p_k$, $t_k$ and $m_k$ for every point, your cubic Hermite spline is completely defined.