https://www.paulinternet.nl/?page=bicubic

Cubic interpolation

If the values of a function f(x) and its derivative are known at x=0 and x=1, then the function can be interpolated on the interval [0,1] using a third degree polynomial. This is called cubic interpolation. The formula of this polynomial can be easily derived.

A third degree polynomial and its derivative:

转载:Cubic interpolation

转载:Cubic interpolation

 

The values of the polynomial and its derivative at x=0 and x=1:

转载:Cubic interpolation

转载:Cubic interpolation

转载:Cubic interpolation

转载:Cubic interpolation

The four equations above can be rewritten to this:

转载:Cubic interpolation

转载:Cubic interpolation

转载:Cubic interpolation

转载:Cubic interpolation

And there we have our cubic interpolation formula.

Interpolation is often used to interpolate between a list of values. In that case we don't know the derivative of the function. We could simply use derivative 0 at every point, but we obtain smoother curves when we use the slope of a line between the previous and the next point as the derivative at a point. In that case the resulting polynomial is called a Catmull-Rom spline. Suppose you have the values p0, p1, p2and p3 at respectively x=-1, x=0, x=1, and x=2. Then we can assign the values of f(0), f(1), f'(0) and f'(1) using the formulas below to interpolate between p1 and p2.

转载:Cubic interpolation

转载:Cubic interpolation

转载:Cubic interpolation

转载:Cubic interpolation

Combining the last four formulas and the preceding four, we get:

转载:Cubic interpolation

转载:Cubic interpolation

转载:Cubic interpolation

转载:Cubic interpolation

So our cubic interpolation formula becomes:

转载:Cubic interpolation

 

For example:

转载:Cubic interpolation


For the green curve:

转载:Cubic interpolation

转载:Cubic interpolation

转载:Cubic interpolation

转载:Cubic interpolation

转载:Cubic interpolation

The first and the last interval

We used the two points left of the interval and the two points right of the inverval as inputs for the interpolation function. But what if we want to interpolate between the first two or last two elements of a list? Then we have no p0 or no p3. The solution is to imagine an extra point at each end of the list. In other words, we have to make up a value for p0 and p3 when interpolating the leftmost and rightmost interval respectively. Two ways to do this are:

    • Repeat the first and the last point.
      Left: p0 = p1
      Right: p3 = p2
    • Let the end point be in the middle of a line between the imaginary point and the point next to the end point.
      Left: p0 = 2p1 - p2
      Right: p3 = 2p2 - p1

相关文章:

  • 2021-08-06
  • 2021-12-03
  • 2021-09-07
  • 2021-09-10
  • 2021-08-31
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-30
  • 2021-12-04
  • 2021-10-11
  • 2021-08-13
相关资源
相似解决方案