转载:Cubic interpolation
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:
The values of the polynomial and its derivative at x=0 and x=1:
The four equations above can be rewritten to this:
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.
Combining the last four formulas and the preceding four, we get:
So our cubic interpolation formula becomes:
For example:
For the green curve:
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
最新文章
- Jquery遮罩插件,想罩哪就罩哪!
- 黑科技装点圣诞节,美国邮政局用AR APP邮寄圣诞包裹
- 如何在Visual Studio中开发自己的代码生成器插件
- sqlite之WAL模式
- windows下PHP5.5.6+Apache2.4.7配置
- Docker container network configuration
- 【NodeJs】Ctrl+C在Linux平台和Windows平台下的TCP连接中的不同表现
- qt 工具栏和菜单栏
- vue2.0 配置build项目打包目录、资源文件(assets\static)打包目录
- Spring MVC 实现文件的上传和下载 (八)
- MFC更换窗口图标
- NEXYS 3开发板练手--LED与数码管时钟
- node-webkit读取json文件
- ElasticSearch 安装root用户启动失败问题解决
- git 使用手册
- wamp安装两个,数据库丢了,怎么办
- Git 克隆指定分支代码
- [Eclipse]自动注释功能
- 使用random函数实现randint函数的功能
- 在razor中使用递归,巧用递归