AKima 插值实现

测量数据的内插已有各种方法,如线性内插、多项式内插、样条函数插值等,但这里的Akima插值法具有独特的优点。线性内插只顾及其附近两点的影响。多项式内插时,低阶多项式由于参数较少,内插精度很低,而使用高阶多项式又会使解不稳定,出现“龙格”现象,即内插函数在插值点与实际数据符合得很好,而在插值点外出现较大的偏差。因此人们又在多项式的基础上发展了分片多项式,即样条函数。样条函数既保持了多项式运算简单的特点,又避免了多项式阶数较高时数值不稳定的缺点,因而得到了广泛的应用。但在样条函数插值中,确定任何一个小区间上的多项式,都要考虑所有数据点对它的影响。这不仅扩大了误差传播的范围,还增加了不少工作量。有时只用内插点附近的几个数据点作为控制点来内插。Aikma插值法和三次样条函数一样考虑了要素导数值的效应,因而得到的整个插值曲线是光滑的。三次样条函数插值法具有最小模、最佳最优逼近和收敛的特性,而Aikma插值法所得曲线比样条函数插值曲线更光顺,更自然。[1]

Akima相关实现的代码:

Akima's original paper:``A new method of interpolation and smooth curve fitting based on local procedures'', Journal of ACM 17, 4 (1970), 589-602

http://student.ndhu.edu.tw/~u9111023/akima.pdf

C implementation

http://packages.debian.org/source/squeeze/spline

C++ implementation

http://www.koders.com/cpp/fid1393B9D668316C1700966643DE0609660B9CB13A.aspx?s=%22Brian+Smith%22

C# implementation

https://github.com/mathnet/mathnet-numerics/blob/master/src/Numerics/Interpolation/Algorithms/AkimaSplineInterpolation.cs

Delphi implementation (see procedure BuildAkimaSpline in delphi/src/spline3.pas)

http://www.alglib.net/translator/re/alglib-2.6.0.delphi.zip

Akima's Fortran 66 implementation

http://cran.r-project.org/web/packages/akima/

Fortran 90 implementation

http://miyoshi.googlecode.com/svn-history/r72/trunk/common/common.f90

Java implementation

http://code.google.com/p/msnlab4/source/browse/trunk/src/br/edu/ufcg/msn/interpolacao/spline/AkimaCubicSplineInterpolator.java?spec=svn83&r=83

Lisp implementation "for AutoCAD 2d-Polylines"

http://autocad.xarch.at/code/candido/akima.lsp

Matlab implementation

http://www.mathworks.se/matlabcentral/fileexchange/1814-akima-interpolation

Pascal implementation (program description)

http://jean-pierre.moreau.pagesperso-orange.fr/Pascal/akima_pas.txt

Python implementation

http://www.lfd.uci.edu/~gohlke/code/akima.py.html

VB6 implementation (see subroutine BuildAkimaSpline in vb6/src/spline3.bas)

http://www.alglib.net/translator/re/alglib-2.6.0.vb6.zip  [2]

参考文献:

[1]聂桂根, and 万剑华. "Akima 插值法在测量中的应用." 测绘科技动态 3 (1998): 31-34.

[2]http://www.mathworks.com/matlabcentral/fileexchange/1814-akima-interpolation

  • 3
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在Qt中实现Akima插值,可以使用Qwt库提供的插值函数。Qwt是一个基于Qt的数据可视化库,提供了许多用于绘制曲线、图表等的控件和函数。以下是一个使用Qwt实现Akima插值的示例代码: ```c++ #include <QApplication> #include <qwt_plot.h> #include <qwt_plot_curve.h> #include <qwt_point_data.h> #include <qwt_plot_grid.h> #include <qwt_legend.h> #include <qwt_scale_draw.h> #include <qwt_scale_widget.h> #include <qwt_plot_renderer.h> #include <qwt_plot_zoomer.h> #include <qwt_plot_panner.h> #include <qwt_picker_machine.h> #include <qwt_picker.h> #include <qwt_plot_magnifier.h> #include <qwt_text.h> #include <qwt_math.h> #include <qwt_scale_engine.h> #include <qwt_interval.h> #include <qwt_plot_renderer.h> #include <qwt_plot_canvas.h> #include <qwt_plot_marker.h> #include <qwt_plot_akima_curve.h> #include <math.h> const int N = 20; const double x[N] = { 0.0, 0.1625, 0.325, 0.4875, 0.65, 0.8125, 0.975, 1.1375, 1.3, 1.4625, 1.625, 1.7875, 1.95, 2.1125, 2.275, 2.4375, 2.6, 2.7625, 2.925, 3.0875 }; const double y[N] = { 0.0, 0.2624, 0.5051, 0.7054, 0.8513, 0.9332, 0.9434, 0.8751, 0.7238, 0.489, 0.1681, -0.289, -0.9014, -1.6304, -2.4764, -3.44, -4.5207, -5.717, -7.0262, -8.4459 }; int main(int argc, char *argv[]) { QApplication a(argc, argv); QwtPlot plot; plot.setTitle("Akima Interpolation"); plot.setCanvasBackground(Qt::white); QwtPlotGrid *grid = new QwtPlotGrid; grid->enableXMin(true); grid->enableYMin(true); grid->setMajorPen(Qt::gray, 0, Qt::DotLine); grid->attach(&plot); QwtLegend *legend = new QwtLegend; legend->setItemMode(QwtLegend::CheckableItem); plot.insertLegend(legend, QwtPlot::RightLegend); QwtPlotAkimaCurve *curve = new QwtPlotAkimaCurve("Akima"); curve->setSamples(x, y, N); curve->attach(&plot); plot.resize(600,400); plot.show(); return a.exec(); } ``` 在上面的代码中,我们使用了QwtPlotAkimaCurve类来实现Akima插值,该类继承自QwtPlotCurve类,具有更高的插值精度和更少的振荡。在代码中,我们首先定义了一组数据点,然后创建了一个QwtPlot对象,设置了标题和背景色,并创建了一个QwtPlotGrid对象用于绘制网格线。接下来,我们创建了一个QwtPlotAkimaCurve对象,并通过setSamples函数将数据点传递给曲线对象。最后,将曲线对象附加到QwtPlot对象上,并显示出来。 需要注意的是,在使用Qwt库前,需要将其添加到Qt项目中。可以在.pro文件中添加以下代码来实现: ```c++ QT += qwt ``` 以上是一个简单的Qt实现Akima插值的示例代码,可以根据自己的需要进行修改和扩展。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值