5.4 三次Hermite插值
- 格式:ppt
- 大小:657.00 KB
- 文档页数:17
三次Hermite插值曲线及曲面的构造与显示摘要曲线曲面造型是计算机几何设计和计算机图形学的1项重要内容,主要研究在计算机图像系统的环境下对曲线曲面的表示、设计、显示和分析。
作为它的1个重要组成部分,Hermite 插值曲线曲面以其特性不仅在几何造型系统中有着广泛的应用,而且在工程设计中也受到了人们的青睐。
本文简要介绍了Hermite插值曲线与Conns曲面的定义和相关定理,阐述了如何构造Ferguson曲面及双3次Conns曲面,对3次Hermite插值曲线曲面的广泛应用也做了相应的举例说明。
文章采用 MATLAB语言来绘制3次Hermite插值曲线及Coons曲面。
matlab语言丰富的图形表现方法,极大的简化了3次Hermite曲线曲面的绘制过程,可以方便地、多样性地实现了可视化,这是其它语言所不能比拟的。
关键词:Hermite插值曲线;合成Ferguson曲线;Coons曲面;MATLAB语言; Abstract The curve surface modeling that is a important content in the computer aided geometric design and computer graphics, it chiefly researchs the expression, design, display and analysis of the curve and surface under the computer image system environment. The Hermite interpolation curve andsurface , as the important component of the curve and surface modeling, that not only has wide application in the geometry modeling system, but also assist many people in the engineering design. This paper introduces the definition and correlative theery of Hermite interpolation curve and the Coons surface briefly, and elaborates how to structure the Ferguson surface and double cubic Coons surface, moreever, this paper also make some corresponding explanations and examples for the wide application of cubic Hermite interpolation curve and suface. This paper uses the MATLAB language to draw up cubic Hermite interpolation curve and Coons surface. There arerichful performance methods of graphics in MATLAB language, this make the drowing process of cubic Hermite curve and surface very easy, and make the accomplishment of visualization conveniently, multiply. These points are useful advantages that other language don’t have. Keywords:Hermite interpolation curve;Complex Ferguson curve;Coons surface;MATLAB language;。
分段三次hermite函数
分段三次 Hermite 函数是一种用于插值数据、拟合数据以及数值微分的函数。
它的特点是可以通过选择足够的基函数来适应各种不同的非线性函数。
本文将深入探讨分段三次 Hermite 函数的定义、应用和优点。
一、定义
分段三次 Hermite 函数是一种三次多项式函数。
它由基函数和插值条件构成。
1. 基函数
1)常数项
2)线性项
3)二次项
这些基函数可以用于构建分段三次 Hermite 函数,使其适应不同的非线性函数。
2. 插值条件
1)值的匹配条件
二、应用
分段三次 Hermite 函数广泛应用于数值微分、插值和拟合。
下面将分别介绍这些应用。
分段三次 Hermite 函数可以用于插值数据。
通过确定插值条件,可以得到一个分段三次 Hermite 函数,使其在给定数据点处与目标函数匹配。
这种方法常常用于构建数值框架,如数值微分和数值积分。
3. 拟合
三、优点
1. 精确度高
2. 稳定性高
分段三次 Hermite 函数具有优良的稳定性。
它可以处理大量的数据,而不会出现精度问题或数值不稳定性。
3. 方便性高
4. 可扩展性高
分段三次 Hermite 函数具有非常强的可扩展性。
它可以扩展到高维空间,适应各种不同的数据类型,从而得到非常精确的结果。
在第一个插值点上的hermite三点插
指公式
在第一个插值点上的hermite三点插指公式
Hermite三点插值法是一种采用三个插值点来求解函数f(x)在给定范围内的曲
线图的插值算法,通常是用来拟合y=f(x)在离散中提供的三个点的插值函数,在
第一个插值点的提出的这种特定的三点插值模型,即对第一个插值点位置
(x0,f(x0)),其中x0为插值点位置,f(x0)为其处的函数值,用的三点模型可写为:
f(x)=f(x0)+f'(x0)(x-x0)+[f''(x0)/2](x-x0)^2
即,把第一个插值点位置(x0,f(x0))处的点代入,可以得到其相应的函数拟合
多项式,当然,并不是每一个函数拟合多项式都能满足实际需求,这就需要注意函数拟合多项式的拟合度,可以在参数估计和函数估计的时候,使用一定的误差来估计函数值,从而获得函数拟合度较好的模型。
此外,在使用Hermite三点插值法时,需要注意三个点之间的位置关系,三个
点位于x0,x1,x2等位置,在确定每个点的位置时应该考虑到它们之间的距离,
一般来说,三个点之间的间距应保持一定,以使插值函数尽可能精确的反映函数的实际变化。
因此,要使得Hermite三点插值法能取得较好的效果,在确定三个插值点的位
置的时候要综合考虑它们之间的位置关系,以及在第一个插值点的估计时要注意拟合度,这样就能很好的进行三点插值,从而得到准确的结果。
数值分析实验六(分段三次Hermite插值)《数值分析》实验报告实验编号:实验六课题名称:分段三次Hermite插值一、算法介绍给定的函数为f(x)=1/(25*x*x+1),将给定区间分成10分,得到11个节点:x[0],x[1],...,x[10],构造插值函数的基函数。
当x在(x[0],x[1])区间上时,H[0] = (x-x[0])*[((x-x[1])/(x[0]-x[1]))^2]。
其余的区间为H[0]=0。
h[0]= [1+2*(x-x[0])/(x[1]-x[0])]*[((x-x[1])/(x[0]-x[1]))^2]。
当x在[x[i-1],x[i]] (i=1,2,3, (9)区间上时,H[i]=(x-x[i])*[((x-x[i-1])/(x[i]-x[i-1]))^2],h[i]=[1+2*(x-x[i])/(x[i-1]-x[i])]*[((x-x[i-1])/(x[i]-x[i-1]))^2)。
当x在(x[i],x[i+1]](i=1,2,3,…,10)区间上其余的区间为H[i]=(x-x[i])[((x-x[i+1])/(x[i]-x[i+1]))^2],h[i]=[1+2*(x-x[i])/(x[i+1]-x[i])]*[((x-x[i+1 ])/(x[i]-x[i+1]))^2]。
其余区间上均为H[i]=0,h[i]=0(i=1,2,…,10)。
当x在(x[9],x[10])区间上时,H[10] = (x-x[9])(((x-x[10])/(x[9]-x[10]))^2).其余的区间为H[10]=0.h[10]= (1+2*((x-x[9])/(x[10]-x[9])))(((x-x[10])/(x[9]-x[10]))^2).其余区间h[10]=0。
构造函数H(x) =∑(y[i]*h[i]+y'[i]*H[i],(i=0,1,…,10)。
二、程序代码// testV iew.cpp : implementation of the CT estV iew class//#include "stdafx.h"#include "test.h"#include "testDoc.h"#include "testView.h"#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE[] = __FILE__;#endif/////////////////////////////////////////////////////////////////// //////////// CTestV iewIMPLEMENT_DYNCREA TE(CTestView, CView)BEGIN_MESSAGE_MAP(CTestView, CView)//{{AFX_MSG_MAP(CTestView)// NOTE - the ClassWizard will add and remove mapping macros here.// DO NOT EDIT what you see in these blocks of generated code!//}}AFX_MSG_MAP// Standard printing commandsON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)ON_COMMAND(ID_FILE_PRINT_DIRECT, CV iew::OnFilePrint) ON_COMMAND(ID_FILE_PRINT_PREVIEW,CView::OnFilePrintPreview)END_MESSAGE_MAP()/////////////////////////////////////////////////////////////////// //////////// CTestV iew construction/destructionCTestView::CTestV iew(){// TODO: add construction code here}CTestView::~CT estView(){}BOOL CTestView::PreCreateWindow(CREA TESTRUCT& cs){// TODO: Modify the Window class or styles here by modifying // the CREA TESTRUCT csreturn CV iew::PreCreateWindow(cs);}/////////////////////////////////////////////////////////////////// //////////// CTestV iew drawingvoid CTestView::OnDraw(CDC* pDC){CTestDoc* pDoc = GetDocument();ASSERT_V ALID(pDoc);// TODO: add draw code for native data hereint i,j,k;double x,y,p_x,p_y,l,xx[100],f[100],F[100],sum,p_sum;CPen MyPen,*OldPen;pDC->SetViewportOrg(400,400); //定义坐标原点for(i=-500;i<500;i++){pDC->SetPixel(0,i,RGB(0,0,0));pDC->SetPixel(i,0,RGB(0,0,0)); //画出坐标}pDC->TextOut(-210,5,"-1");pDC->TextOut(196,5,"1");//原函数MyPen.CreatePen(PS_SOLID,1,RGB(255,0,0));//定义画笔颜色OldPen=pDC->SelectObject(&MyPen);x=-1.0,y=1/(1+25*x*x);p_x=x*200;p_y=-y*200;pDC->MoveTo(p_x,p_y);for (x=-1.0;x<=1.0;x+=0.0001){y=1/(1+25*x*x);p_x=x*200;p_y=-y*200;pDC->LineT o(p_x,p_y);}pDC->SelectObject(OldPen);MyPen.DeleteObject();//分段三次Hermite插值MyPen.CreatePen(PS_SOLID,1,RGB(0,0,0)); OldPen=pDC->SelectObject(&MyPen); x=-1.0,y=1.0/(1+25*x*x);p_x=x*200;p_y=-y*200;pDC->MoveTo(p_x,p_y);x=-1.0;for(i=0;i<=10;i++){f[i]=1/(1+25*x*x);xx[i]=x;F[i]=-50*x/(1+25*x*x)/(1+25*x*x); //导数x+=0.2;}x=-1.0;for(j=0;j<=1000;j++){sum=0;for(i=0;i<=10;i++){if(x==xx[i]){sum=f[i];p_x=x*200,p_y=-sum*200;pDC->LineT o(p_x,p_y);break;}if(xxx[i]){y=(1+2*(x-xx[i])/(xx[i+1]-xx[i]))*(x-xx[i+1])*(x-xx[i+1])/(xx[i]-xx[i+1])/(xx[i]-xx[i+1]);sum+=f[i]*y;y=(1+2*(x-xx[i+1])/(xx[i]-xx[i+1]))*(x-xx[i])*(x-xx[i])/(xx[i+1]-xx[i])/(xx[i+1]-xx[i]);sum+=f[i+1]*y;y=(x-xx[i])*(x-xx[i+1])*(x-xx[i+1])/(xx[i]-xx[i+1])/(xx[i]-xx[i+1]);sum+=F[i]*y;y=(x-xx[i+1])*(x-xx[i])*(x-xx[i])/(xx[i+1]-xx[i])/(xx[i+1]-xx[i]);sum+=F[i+1]*y;p_x=x*200;p_y=-sum*200;pDC->LineT o(p_x,p_y);break;}}x+=0.002;}pDC->SelectObject(OldPen);MyPen.DeleteObject();/////////////////////////////////////////////////////////////////// //////////// CTestV iew printingBOOL CTestView::OnPreparePrinting(CPrintInfo* pInfo){// default preparationreturn DoPreparePrinting(pInfo);}void CTestView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/){// TODO: add extra initialization before printing}void CTestView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/){// TODO: add cleanup after printing}/////////////////////////////////////////////////////////////////// //////////// CTestV iew diagnostics#ifdef _DEBUGvoid CTestView::AssertV alid() const{CView::AssertV alid();}void CTestView::Dump(CDumpContext& dc) const{CView::Dump(dc);CTestDoc* CT estV iew::GetDocument() // non-debug version is inline{ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CT estD oc)));return (CT estDoc*)m_pDocument;}#endif //_DEBUG/////////////////////////////////////////////////////////////////// //////////// CTestV iew message handlers三、运算结果截屏红色的曲线为原函数图像,黑色曲线为分段三次Hermite插值曲线四、算法分析上述图像中黑色的曲线为分段分段三次Hermite插值多项式所对应的图像,由图像可看出黑色的分段三次Hermited插值函数图像和拉格朗日、分段线性插值相比与红色被逼近函数的重合度最好,说明分段三次Hermite插值在函数的各节点两边插值函数的导数是相等的,保证了在各节点的平滑性,且不会出现Runge现象。
实验六: 分段三次Hermite插值画函数图像学号: 姓名:指导老师:马季骕班级:计算机科学与技术(非师范)1、算法说明:分段三次Hermit插值的做法是在每一个小区间上作三次Hermit插值,因此在每一个插值节点上都需要构造两个插值基函数,然后再作它们的线性组合。
分段三次Hermit插值基函数如下:H(x)=Σ(yihi(x)+y’iHi(x))给定的函数为f(x)=1/(25*x*x+1),将给定区间分成10分,得到11个节点:x[0],x[1],...,x[10],构造插值函数的基函数。
当x在(x[0],x[1])区间上时,H[0] = (x-x[0])*[((x-x[1])/(x[0]-x[1]))^2]。
其余的区间为H[0]=0。
h[0]= [1+2*(x-x[0])/(x[1]-x[0])]*[((x-x[1])/(x[0]-x[1]))^2]。
当x在[x[i-1],x[i]] (i=1,2,3,...,9)区间上时,H[i]=(x-x[i])*[((x-x[i-1])/(x[i]-x[i-1]))^2],h[i]=[1+2*(x-x[i])/(x[i-1]-x[i])]*[((x-x[i-1])/(x[i]-x[i-1]))^2)。
当x在(x[i],x[i+1]](i=1,2,3, (10)区间上其余的区间为H[i]=(x-x[i])[((x-x[i+1])/(x[i]-x[i+1]))^2],h[i]=[1+2*(x-x[i])/(x[i+1]-x[i])]*[((x-x[i+1])/(x[i]-x[i+ 1]))^2]。
其余区间上均为H[i]=0,h[i]=0(i=1,2,…,10)。
当x在(x[9],x[10])区间上时,H[10] = (x-x[9])(((x-x[10])/(x[9]-x[10]))^2).其余的区间为H[10]=0.h[10]= (1+2*((x-x[9])/(x[10]-x[9])))(((x-x[10])/(x[9]-x[10]))^2).其余区间h[10]=0。