-1-实验报告实验课程:数值分析学生代号:信念学号:5215201314专业班级:网络间谍088班2010年12月20日-2-目录一、用样条插值法插值的方法生成字体T的轮廓………………………3二、高斯消去法的实现………………………………………………8-3-南昌大学实验报告一学生代号:信念学号:5215201314专业班级:网络间谍088班实验类型:□验证□综合■设计□创新实验日期:2010.11.4实验成绩:一、实验目的1:用样条插值的方法生成字体T的轮廓2:C或C++语言用Bezier曲线生成并编写程序二、实验基本原理和内容Times-Roman字体:TP0xP0yP1xP1yP2xP2yP3xP3y2376202376202371202371202371202373522624143191431914319143014301430143043504350435043504351943519435193532333936339109339109339108339620339620339620507620529602552492552492552492576492576492576492576492570662570662570662570662666266626662666204920492049204922449224492244924866271620183620183620183620237620237620Bezier曲线生成:1、确定曲线的阶次;2计算Bernstein基函数的表达式:生成字体T共分成15段,每段用了三次的代数方程,用Bezier曲线生成nktttknknttCtBknkknkknnk,,1,0]1,0[)1()!(!!)1()(,-4-当n=3时303333,3212233,2221133,1330033,0)1()()1(3)1()()1(3)1()()1()1()(tttCtBttttCtBttttCtBtttCtB其中]1,0[t)()()()()(3,333,223,113,00tBPtBPtBPtBPtP3把Bezier曲线中的Pk写成分量坐标的形式4确定一合适的步长;控制t从0到1变化,求出一系列(x,y)坐标点;将其用小线段顺序连接起来。算法描述:对于二维平面的情况,只有x,y坐标分量,可以给出四点三次Bezier曲线如下的算法描述:输入:阶次,3;控制顶点:4个,(x0,y0),…,(x3,y3)beginx=x0y=y0moveto(x,y)fort﹦0to1steptx﹦B0,3(t)x0﹢B1,3(t)x1﹢B2,3(t)x2﹢B3,3(t)x3y﹦B0,3(t)y0﹢B1,3(t)y1﹢B2,3(t)y2﹢B3,3(t)y3lineto(x,y)endforend三次Bezier曲线例子:对于平面上给定的7个控制点坐标分别为:A(100,300),B(120,200),C(220,200),D(270,100),E(370,100),F(420,200),G(420,300)。画出其三次Bezier曲线:-5-三、主要仪器设备及耗材PC微机Windows操作系统MicrosoftVisualStudio6.0集成开发环境MicrosoftVisualStudio6.0集成开发环境的MSDN四、实验程序及运行结果实验程序代码如下voidCCharTView::OnDraw(CDC*pDC){CCharTDoc*pDoc=GetDocument();ASSERT_VALID(pDoc);if(!pDoc)return;pDC-SetMapMode(MM_LOENGLISH);pDC-SetViewportOrg(350,500);floati=0.00;for(i=0;i1;i+=0.001){pDC-SetPixel(CalPoint(CPoint(237,620),CPoint(237,620),CPoint(237,120),CPoint(237,120),i),RGB(255,0,0));pDC-SetPixel(CalPoint(CPoint(237,120),CPoint(237,35),CPoint(226,-6-24),CPoint(143,19),i),RGB(255,0,0));pDC-SetPixel(CalPoint(CPoint(143,19),CPoint(143,19),CPoint(143,0),CPoint(143,0),i),RGB(255,0,0));pDC-SetPixel(CalPoint(CPoint(143,0),CPoint(143,0),CPoint(435,0),CPoint(435,0),i),RGB(255,0,0));pDC-SetPixel(CalPoint(CPoint(435,0),CPoint(435,0),CPoint(435,19),CPoint(435,19),i),RGB(255,0,0));pDC-SetPixel(CalPoint(CPoint(435,19),CPoint(353,23),CPoint(339,36),CPoint(339,109),i),RGB(255,0,0));pDC-SetPixel(CalPoint(CPoint(339,109),CPoint(339,108),CPoint(339,620),CPoint(339,620),i),RGB(255,0,0));pDC-SetPixel(CalPoint(CPoint(339,620),CPoint(507,620),CPoint(519,662),CPoint(552,492),i),RGB(255,0,0));pDC-SetPixel(CalPoint(CPoint(552,492),CPoint(552,492),CPoint(576,492),CPoint(576,492),i),RGB(255,0,0));pDC-SetPixel(CalPoint(CPoint(576,492),CPoint(576,492),CPoint(570,662),CPoint(570,662),i),RGB(255,0,0));pDC-SetPixel(CalPoint(CPoint(570,662),CPoint(570,662),CPoint(6,662),CPoint(6,662),i),RGB(255,0,0));pDC-SetPixel(CalPoint(CPoint(6,662),CPoint(6,662),CPoint(0,492),CPoint(0,492),i),RGB(255,0,0));pDC-SetPixel(CalPoint(CPoint(0,492),CPoint(0,492),CPoint(24,492),CPoint(24,492),i),RGB(255,0,0));pDC-SetPixel(CalPoint(CPoint(24,492),CPoint(48,662),CPoint(71,620),CPoint(183,620),i),RGB(255,0,0));pDC-SetPixel(CalPoint(CPoint(183,620),CPoint(183,620),CPoint(237,620),CPoint(237,620),i),RGB(255,0,0));}CPointCCharTView::CalPoint(CPointpoint0,CPointpoint1,CPointpoint2,CPointpoint3,floatt)-7-{CPointpt;pt.x=point0.x*(1-t)*(1-t)*(1-t)+point1.x*3*t*(1-t)*(1-t)+point2.x*3*(t*t)*(1-t)+point3.x*(t*t*t);pt.y=point0.y*(1-t)*(1-t)*(1-t)+point1.y*3*t*(1-t)*(1-t)+point2.y*3*(t*t)*(1-t)+point3.y*(t*t*t);returnpt;}}运行结果显示为:-8-南昌大学实验报告二学生代号:信念学号:5215201314专业班级:网络间谍088班实验类型:□验证□综合■设计□创新实验日期:2010-12-5实验成绩:一、实验目的用C语言或C++语言编程实现高斯消去法。二、实验基本原理和内容基本思想:用高斯消去法求解线性方程组的基本思想是设法消去方程组的系数矩阵A的主对角线下的元素,而将Ax=b化为等价的上三角形方程组,然后再通过回代过程便可以获得方程组的解。这种解线性方程组的方法,常称为高斯消去法。高斯消去法算法的构造:记方程组AX=b为A(1)X=b(1),其中,A(1)和b(1)的元素分别记为.,,2,1,)1()1(njibaiij、、Step1:第一次消元设0)1(11a,将增广矩阵的第i行减去)1(11)1(11/aamii倍,(i=2,…,n),目的是将增广矩阵的第一列内除每一个元素不变外,其余全部消为零,得到A(2)X=b(2),即-9-][...0...0............][)2()2()2()2()2(2)2(2)2(2)2(22)1(1)1(1)1(12)1(11)1()1()1(2)1(1)1(2)1(2)1(22)1(21)1(1)1(1)1(12)1(11)1()1(bAbaabaabaaabaaabaaabaaabAnnnnnnnnnnnnn其中)...,,2,()1(11)1()2()1(11)1()2(njibmbbamaaiiijiijijStep2:第k次消元(12nk)设第k-1次消元已完成,且0)(kkka,得到A(k)X=b(k),即)()()()()()()2(2)2(2)2(2)2(22)1(1)1(1)1(1)1(12)1(11)()(][knknnkknkkkknkkknknkkkbaabaabaaabaaaabA计算因子)...,,1(/)()(nkiaamkkkkikik,)...,,1,()()()1()()()1(nkjibmbbamaakkikkikikkjikkijkij如此反复,经过n-1次消元之后得到一个与原方程组等价的上三角形方程组.-10-)()2(2)1(121)()2(2)2(22)1(1)1(12)1(11)()(...............][nnnnnnnnnnbbbxxxaaaaaabAStep3:回代只要0)(nnna就可以回代求解)()(/nnnnnnabx)1...,,1()(1)()(niaxabxiiinijjiijiii高斯消去法的算法Step1消元:对k=1,2,…,n-1若0)(kkka则停止计算对i=k+1,k+2,…,n计算因子)()(/kkkkikikaam;对j=k+1,k+2,…,n计算)()()1()()()1(kkikkikikkjikkijkijbmbbamaa;Step2回代:对i=n,n-1,…,1)(1)()(iiinijjiijiiiaxabx-11-(高斯消去法的条件)若A的所有顺序主子式均不为0,则高斯消元无需换行即可进行到底,且得到唯一解.若消元过程中允许对增广矩阵进行行交换,则方程组Ax=b可用消去法求解的充要条件是A可逆.三、主要仪器设备及耗材PC机一台PC微机