freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

計(jì)算機(jī)圖形學(xué)第1-5章課后習(xí)題參考答案(編輯修改稿)

2025-07-15 18:58 本頁(yè)面
 

【文章內(nèi)容簡(jiǎn)介】 void main() //主函數(shù)的實(shí)現(xiàn){ int graphdriver=DETECT,graphmode。 initgraph(amp。graphdriver,amp。graphmode,E:\\tc3\\bgi)。 setbkcolor(15)。 DPOINT* p。 p=new DPOINT[10]。 p[0].x=。 p[0].y=。 p[1].x=。 p[1].y=。 p[2].x=。 p[2].y=。 p[3].x=。 p[3].y=。 p[4].x=。 p[4].y=。 p[5].x=。 p[5].y=。 p[6].x=。 p[6].y=。 p[7].x=。 p[7].y=。 p[8].x=。 p[8].y=。 p[9].x=。 p[9].y=。 Bezier bzr(p,10)。 ()。 delete p。 getch()。closegraph()。}10. 編寫(xiě)一個(gè)繪制B樣條曲線(xiàn)的程序。該程序根據(jù)以下數(shù)據(jù)點(diǎn)[x, y]:P0[50, 130] P1[120, 40] P2[100, 270]和P3[140, 160]計(jì)算出結(jié)果,并實(shí)現(xiàn)兩段首尾相接的兩次B樣條曲線(xiàn)在屏幕上顯示的功能,采用了C++語(yǔ)言實(shí)現(xiàn);將已知點(diǎn)代入式(419)可得兩段兩次B樣條曲線(xiàn)方程:P1(t)= [ t2 t 1] =[45 160]t2 +[70 90]t +[85 85]P2(t)= [ t2 t 1] = [30 170]t2 +[20 230]t +[110 155]include include include typedef struct{ double x,y。} DPOINT。 //定義結(jié)構(gòu)體class B_Spline //定義B樣條曲線(xiàn)類(lèi){ private: DPOINT* bP。 int m_maxIndex。 //有多少個(gè)型值點(diǎn) void drawFrame()。 void drawCurve()。 void drawCurve(int p0,int p1,int p2)。 public: B_Spline(DPOINT* p,int len)。 //定義構(gòu)造函數(shù) void draw()。}。B_Spline::B_Spline(DPOINT* p,int len) //構(gòu)造函數(shù)的實(shí)現(xiàn){ this bP=p。 m_maxIndex=len。}void B_Spline::draw() //通過(guò)公有函數(shù)調(diào)用私有函數(shù){ drawFrame()。 drawCurve()。}void B_Spline::drawFrame() //其功能是繪制出多邊形和各個(gè)端點(diǎn){ setcolor(12)。 for(int i=0。im_maxIndex1。i++) { line( bP[i].x, bP[i].y, bP[i+1].x, bP[i+1].y )。 //繪制多邊形 circle(bP[i].x, bP[i].y,5)。 //繪制多邊形各個(gè)端點(diǎn) } circle(bP[m_maxIndex1].x,bP[m_maxIndex1].y,5)。}void B_Spline::drawCurve() //實(shí)現(xiàn)多段B樣條曲線(xiàn)繪制的功能{ for(int i=0。im_maxIndex2。i++) { drawCurve(i,i+1,i+2)。 }}void B_Spline::drawCurve(int p0,int p1,int p2) //實(shí)現(xiàn)繪制某一段Bezier曲線(xiàn)的功能{ double tmpx=。 double tmpy=。 double t=。 for(。t=。t+=) { tmpx=(*bP[p0].xbP[p1].x+*bP[p2].x)*t*t+(bP[p0].x+bP[p1].x)*t+*bP[p0].x+*bP[p1].x。 tmpy=(*bP[p0].ybP[p1].y+*bP[p2].y)*t*t+(bP[p0].y+bP[p1].y)*t+*bP[p0].y+*bP[p1].y。 putpixel(tmpx,tmpy,3)。 }}void main() //主函數(shù)的實(shí)現(xiàn){ int graphdriver=DETECT,graphmode。 initgraph(amp。graphdriver,amp。graphmode,)。 //圖形初始化 setbkcolor(15)。 DPOINT* p。 p=new DPOINT[4]。 p[0].x=。 p[0].y=。 p[1].x=。 p[1].y=。 p[2].x=。 p[2].y=。 p[3].x=。 p[3].y=。 B_Spline b_sp(p,4)。 ()。 delete p。 getch()。closegraph()。}11. 簡(jiǎn)述NURBS曲線(xiàn)產(chǎn)生的背景和特點(diǎn)?答:NURBS曲線(xiàn)具有局部可調(diào)性、凸包性、幾何和透視投影變換不變性等等,它采用有理參數(shù)多項(xiàng)式可以精確表示圓錐曲線(xiàn)、二次曲面等,對(duì)于幾何造型算法提供了思路。12. 將下列數(shù)據(jù) X 2 6 10 12 14 16 Y 3 8 11 13 15 17按最小二乘法曲線(xiàn)擬合,分別求一次和二次多項(xiàng)式曲線(xiàn),擬合以上數(shù)據(jù)并畫(huà)圖表示。解:如下表所示:i1236412816268483628821612963101111010011001000100004121315614418721728207365141521019629402744384166161727225643524096655366067802736105649792136000一次多項(xiàng)式的情形: 6+60=67 = 60+736=802 =所求多項(xiàng)式為y=f(x)=+ 二次多項(xiàng)式的情形: 6+60+736=67 = 60+736+9792=802 = 736+9792+136000=10564 =所求多項(xiàng)式為y=f(x)=+13. 設(shè)五邊形的五個(gè)頂點(diǎn)坐標(biāo)為(10, 10),(15, 5),(12, 5),(8, 2)和(4, 5),利用多邊形區(qū)域填充算法,編一程序生成一個(gè)實(shí)心圖。解:假設(shè)以上五個(gè)頂點(diǎn)依次對(duì)應(yīng)編號(hào)ABCDE,首先計(jì)算得到ET表:AEDCB…1046/5EA10151BA 610 5 4584/3DE584/3DC 3 2 1 0 用于存放AET活動(dòng)邊表該多邊形的AET指針的內(nèi)容為:1 AET為空584/3DE584/3DCAET2DCDEAET54/328/34/320/353DE4/316/354/332/35DCAET46/54104/345DCEAAET5DE4/312511510BA1410BAEA6/526/510AET16BAEA6/532/510AET113107EA6/538/510AET11210BA810AET11110BAEA44/56/591010BAEA6/51010AET110具體編程實(shí)現(xiàn)如下:第1步:(1) 根據(jù)輸入的五個(gè)頂點(diǎn)坐標(biāo)找到y(tǒng)值最小的點(diǎn)(例如點(diǎn)D,此時(shí)y=2),并找到與D有邊關(guān)系的兩個(gè)頂點(diǎn)(此時(shí)為E和C),在y=2處建立ET邊表記錄(ymax、xi和m值均可通過(guò)頂點(diǎn)坐標(biāo)間的計(jì)算得到,例如DE邊的建立,特別注意:當(dāng)D點(diǎn)和E點(diǎn)y坐標(biāo)值相同時(shí),也即是DE與x軸平行,該邊不能計(jì)入ET邊表),之后標(biāo)記D點(diǎn)被訪(fǎng)問(wèn)過(guò);(2) 排除訪(fǎng)問(wèn)過(guò)的點(diǎn)以及和該點(diǎn)相關(guān)聯(lián)的邊,重復(fù)(1)直至將ET表建立完善。[注]邊關(guān)系的建立可通過(guò)鄰接矩陣的數(shù)據(jù)結(jié)構(gòu)實(shí)現(xiàn),權(quán)值可以為該矩陣行編號(hào)對(duì)應(yīng)點(diǎn)的y坐標(biāo)值,ET邊表采用鄰接表的數(shù)據(jù)結(jié)構(gòu)第2步:根據(jù)ET表構(gòu)建AET表,并逐行完成多邊形填充,具體的C++代碼如下:(1) ,主要是邊表結(jié)點(diǎn)結(jié)構(gòu)體和ET邊表類(lèi)的實(shí)現(xiàn)enum ResultCode{Success, Failure}。template class Tstruct Enode{ Enode() {next=NULL。} Enode(T pymax, float pxi, float pm, Enode *pnext) { ymax=pymax。 xi=pxi。 m=pm。 next=pnext。 } T ymax, xi。 //ymax表示最大的y值,xi表示最底端點(diǎn)的x坐標(biāo)值 float m。 //m表示斜率的倒數(shù) Enode *next。}。 //定義了ET表和AET表中結(jié)點(diǎn)的結(jié)構(gòu)體template class Tclass ET{ public: ET(int mSize)。 ~ET()。 ResultCode Insert(int u, T ymax, float xi, float m)。 int n。 //覆蓋該多邊形的掃描線(xiàn)的總數(shù),從0開(kāi)始計(jì)數(shù) EnodeT **a。}。 //定義了邊表類(lèi)template class TETT::ET(int mSize){ n=mSize。 a=new EnodeT *[n]。 for(int i=0。in。i++) a[i]=0。} //ET邊表的初始化template class TETT::~ET(){ EnodeT *p, *q。 delete a[0]。 for(int i=1。in。i++) { p=a[i]。 q=p。 while(p) { p=pnext。 delete q。 q=p。 } } delete []a。} //析構(gòu)函數(shù)負(fù)責(zé)回收內(nèi)存空間template class TResultCode ETT::Insert(int u, T ymax, float xi, float m){ if(u0||un1) return Failure。 EnodeT *p=new EnodeT(ymax, xi, m, a[u])。 a[u]=p。 return Success。} //依次插入結(jié)點(diǎn)構(gòu)建出邊表,其中a[1]到a[10]用于構(gòu)建ET邊表 //a[0]用于構(gòu)建活動(dòng)AET邊表(2) 填充函數(shù)po_fill的實(shí)現(xiàn)和主函數(shù)的實(shí)現(xiàn)include include include void po_fill(ETint amp。etp, int ep, int color) //多邊形填充函數(shù)的實(shí)現(xiàn){ int i=1。 //i作為控制變量標(biāo)識(shí)掃描線(xiàn) while(iep1) { if([i]!=NULL) { Enodeint *p,*r。 p=[i]。 r=[0]。 while(p) { Enodeint *q=new Enodeint(pymax,pxi,pm,NULL)。 if(![0]) {[0]=q。 r=q。} else { if(rxi==qxi) {qnext=rnext。 rnext=q。 r=q。} if(rxiqxi) {[0]=q。 qnext=r。} else { while(qxirxi amp。amp。 rnext) r=rnext。 if(rnext) {qnext=rnext。 rnext=q。 } else {rnext=q。 qnext=NULL。} } } p=pnext。 } } //按照xi值的大小將當(dāng)前ET表中的記錄放置到AET表中 Enodeint *f,*g。 if([0]) { f=[0]。 while(fnext) { g=f。 f=
點(diǎn)擊復(fù)制文檔內(nèi)容
環(huán)評(píng)公示相關(guān)推薦
文庫(kù)吧 www.dybbs8.com
備案圖片鄂ICP備17016276號(hào)-1