vtk中插值拟合成线的函数

来源:互联网 发布:mac os x 版本升级 编辑:程序博客网 时间:2024/05/22 00:44

根据点进行样条插值拟合成曲线

    vtkPoints *points = vtkPoints::New();    points->InsertPoint(0, 0.0, 0.0, 0.0);    points->InsertPoint(1, 1.0, 1.0, 1.0);    points->InsertPoint(2, 1.0, 0.0, 0.0);    points->InsertPoint(3, 1.0, 0.0, 1.0);    //插值为样条曲线      vtkParametricSpline *spline = vtkParametricSpline::New();    spline->SetPoints(points);    spline->ClosedOff();    vtkParametricFunctionSource *splineSource = vtkParametricFunctionSource::New();    splineSource->SetParametricFunction(spline);    vtkPolyDataMapper *splineMapper = vtkPolyDataMapper::New();    splineMapper->SetInputConnection(splineSource->GetOutputPort());    vtkActor *splineActor = vtkActor::New();    splineActor->SetMapper(splineMapper);    splineActor->GetProperty()->SetColor(0.3800, 0.7000, 0.1600);

根据vtk官网中的描述:
*vtkParametricSpline is a parametric function for 1D interpolating splines. vtkParametricSpline maps the single parameter u into a 3D point (x,y,z) using three instances of interpolating splines. This family of 1D splines is guaranteed to be parameterized in the interval [0,1]. Attempting to evaluate outside this interval will cause the parameter u to be clamped in the range [0,1].
When constructed, this class creates instances of vtkCardinalSpline for each of the x-y-z coordinates. The user may choose to replace these with their own instances of subclasses of vtkSpline*.

vtkParametricSpline 为vtkCardinalSpline,使用者也可以继承vktSpline这个类来写一个函数做插值拟合。
插值结果当然还有一个继承Hermite的为vtkKochenekSpline,vtk官网还提供了vtkSCurve S型曲线拟合的方式,三者测试结果如下图所示:
这里写图片描述
后续还需要分析这三者插值的方式,具体到数学公式这一块。