实验五分段线性插值画函数图像

上传人:飞*** 文档编号:47460949 上传时间:2018-07-02 格式:PDF 页数:11 大小:98.41KB
返回 下载 相关 举报
实验五分段线性插值画函数图像_第1页
第1页 / 共11页
实验五分段线性插值画函数图像_第2页
第2页 / 共11页
实验五分段线性插值画函数图像_第3页
第3页 / 共11页
实验五分段线性插值画函数图像_第4页
第4页 / 共11页
实验五分段线性插值画函数图像_第5页
第5页 / 共11页
点击查看更多>>
资源描述

《实验五分段线性插值画函数图像》由会员分享,可在线阅读,更多相关《实验五分段线性插值画函数图像(11页珍藏版)》请在金锄头文库上搜索。

1、实验五: 分段线性插值画函数图像学号: 姓名: 指导老师:马季骕班级: 计算机科学与技术(非师范)1、算法说明 :所谓分段线性插值就是通过插值点用折线段连接起来逼近f( x) 。设已知节点a=x0LoadIcon(IDR_MAINFRAME); void CMyDlg:DoDataExchange(CDataExchange* pDX) CDialog:DoDataExchange(pDX); /AFX_DATA_MAP(CMyDlg) / NOTE: the ClassWizard will add DDX and DDV calls here /AFX_DATA_MAP BEGIN_MES

2、SAGE_MAP(CMyDlg, CDialog) /AFX_MSG_MAP(CMyDlg) ON_WM_SYSCOMMAND() ON_WM_PAINT() ON_WM_QUERYDRAGICON() ON_BN_CLICKED(IDC_NEW, OnNew) ON_BN_CLICKED(IDC_LAG, OnLag) ON_BN_CLICKED(IDC_LINE, OnLine) ON_BN_CLICKED(IDC_HER, OnHer) /AFX_MSG_MAP END_MESSAGE_MAP() / / CMyDlg message handlers BOOL CMyDlg:OnIni

3、tDialog() CDialog:OnInitDialog(); / Add “About.“ menu item to system menu. / IDM_ABOUTBOX must be in the system command range. ASSERT(IDM_ABOUTBOX ASSERT(IDM_ABOUTBOX AppendMenu(MF_SEPARATOR); pSysMenu-AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); / Set the icon for this dialog. The framework d

4、oes this automatically / when the applications main window is not a dialog SetIcon(m_hIcon, TRUE); / Set big icon SetIcon(m_hIcon, FALSE); / Set small icon / TODO: Add extra initialization here return TRUE; / return TRUE unless you set the focus to a control void CMyDlg:OnSysCommand(UINT nID, LPARAM

5、 lParam) if (nID dlgAbout.DoModal(); else CDialog:OnSysCommand(nID, lParam); / If you add a minimize button to your dialog, you will need the code below / to draw the icon. For MFC applications using the document/view model, / this is automatically done for you by the framework. void CMyDlg:OnPaint(

6、) if (IsIconic() CPaintDC dc(this); / device context for painting SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); / Center icon in client rectangle int cxIcon = GetSystemMetrics(SM_CXICON); int cyIcon = GetSystemMetrics(SM_CYICON); CRect rect; GetClientRect( int x = (rect.Width() - cxIc

7、on + 1) / 2; int y = (rect.Height() - cyIcon + 1) / 2; / Draw the icon dc.DrawIcon(x, y, m_hIcon); else CDialog:OnPaint(); / The system calls this to obtain the cursor to display while the user drags / the minimized window. HCURSOR CMyDlg:OnQueryDragIcon() return (HCURSOR) m_hIcon; void CMyDlg:OnNew

8、() / TODO: Add your control notification handler code here int i; int j; int x00=331; int y00=225; double x; CDC *pDC=GetDC(); pDC-SetMapMode(MM_LOMETRIC); pDC-SetViewportOrg(x00,y00); for(i=-750; iSetPixel(i,0,RGB(0,0,0); pDC-SetPixel(0,i,RGB(0,0,0); for(x=-1; xSetPixel(x*500,j,RGB(0,0,0); void CMy

9、Dlg:OnLag() / TODO: Add your control notification handler code here int i; int j; int x00=331; int y00=225; double x; CDC *pDC=GetDC(); pDC-SetMapMode(MM_LOMETRIC); pDC-SetViewportOrg(x00,y00); for(i=-750; iSetPixel(i,0,RGB(0,0,0); pDC-SetPixel(0,i,RGB(0,0,0); double yx=-1,-0.8,-0.6,-0.4,-0.2,0,0.2,

10、0.4,0.6,0.8,1; double yy12,lx12,ly12; double l_fenzi12,l_fenmu12; double l_x,l_y; for(i=0; iSetPixel(qq*500,pp*390+5,RGB(150,12,25); void CMyDlg:OnLine() / TODO: Add your control notification handler code here int i; int j; int x00=331; int y00=225; double x; CDC *pDC=GetDC(); pDC-SetMapMode(MM_LOME

11、TRIC); pDC-SetViewportOrg(x00,y00); for(i=-750; iSetPixel(i,0,RGB(0,0,0); pDC-SetPixel(0,i,RGB(0,0,0); double yx=-1,-0.8,-0.6,-0.4,-0.2,0,0.2,0.4,0.6,0.8,1; double yy14; for(i=0; iSelectObject( for(i=0; iMoveTo(yxi*480,yyi*400); pDC-LineTo(yxi+1*480,yyi+1*400); void CMyDlg:OnHer() / TODO: Add your c

12、ontrol notification handler code here int x00=331,y00=225,i,j; double x; CDC *pDC=GetDC(); pDC-SetMapMode(MM_LOMETRIC); pDC-SetViewportOrg(x00,y00); for(i=-750; iSetPixel(i,0,RGB(0,0,0); pDC-SetPixel(0,i,RGB(0,0,0); double yx=-1,-0.8,-0.6,-0.4,-0.2,0,0.2,0.4,0.6,0.8,1; double yy12; for(i=0; iSetPixel(qq*500,pp*400,RGB(255,215,0); 3、实验结果 :4、结果分析 :分段线性插值的方法克服了Lagrange 插值法当节点不断加密时,构造的插值多项式的次数不断升高,高次多项式虽然是连续的,但是不一定都收敛到相应的被插函数而产生Runge 现象。分段线性插值因为在每一段小区间上都是线性插值而极大地降低了插值多项式的次数,从几何图形上可以看出,当节点取得较多时插值函数的逼近效果还是很好的,但是所求函数是一条以型值点为顶点的折线,这也表现出了它的缺点就是所求得的插值函数的光滑性较差。

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 行业资料 > 其它行业文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号