


版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
1、計算機圖形學(xué)實驗報告(實驗四 ,.Bezier曲線生成算法實現(xiàn)一、實驗?zāi)康募耙笕?Bezier曲線及 de Casteljau算法以及 b樣條曲線二、理論基礎(chǔ)詳見教材!三、算法設(shè)計與分析Bezier 曲線生成算法int degree=3,i,x,y;float t;float coeff_x4=50.0,200.0,200.0,500.0;float coeff_y4=50.0,300.0,50.0,200.0;pDC->MoveTo(coeff_x0,coeff_y0; for(i=1;i<=3;i+ pDC->LineTo(coeff_xi,coeff_yi;for(
2、t=0;t<=1;t+=0.001x=hornbez(degree,coeff_x,t; y=hornbez(degree,coeff_y,t; pDC->SetPixel(x,y,RGB(0,0,0;float CMy2View:hornbez(int degree,float coeff,float tint i,n_choose_i;float fact,t1,aux;t1=1.0-t;fact=1.0;n_choose_i=1;aux=coeff0*t1;for(i=1;ifact =fact*t;n_choose_i=n_choose_i*(degree-i+1/i;au
3、x=(aux+fact*n_choose_i*coeffi*t1;aux=aux+fact*t*coeffdegree;return aux;de Casteljau 算法void CTuView:bezpoint(int degree,int npoints,float *coeff,float points float t,delt;int i;delt=1.0/(floatnpoints;t=0.0;for (i=0;ipointsi=decas(degree,coeff,t;t=t+delt;float CTuView:decas(int degree,float *coeff,flo
4、at t int r,i;float t1;float coeffa10;t1=1.0-t;for (i=0;i<=degree;i+coeffai=coeffi; for(r=1;r<=degree;r+for (i=0;i<=degree-r;i+ coeffai=t1*coeffai+t*coeffai+1;return coeffa0;主函數(shù):void CTuView:OnDraw(CDC* pDCCTuDoc* pDoc = GetDocument(; ASSERT_VALID(pDoc;/ TODO: add draw code for native data h
5、ereint degree=5,npoints=1000,i;float coeffx=10,40,265,300,400,500;float coeffy=20,130,160,90,300,100;float points11000,points21000;for (i=0;ipDC->MoveTo(intcoeffxi,(intcoeffyi;pDC->LineTo (intcoeffxi+1,(intcoeffyi+1;bezpoint(degree,npoints,coeffx,points1;bezpoint(degree,npoints,coeffy,points2;
6、for(i=0;ipDC->SetPixel(intpoints1i,(intpoints2i,RGB(123,123,123;B 樣條曲線void CBView:bsp(int degree,int l,float *coeff,float*knot,int dense,float *points,int *point_numint i,ii;float u;*point_num=0;for(i=degree-1;iif(knoti+1>knoti for(ii=0;iiu=knoti+ii*(knoti+1-knoti/dense; points*point_num=deboo
7、r(degree,coeff,knot,u,i; *point_num=(*point_num+1;float CBView:deboor(int degree,float *coeff,float *knot,float u,int iint k,j;float t1,t2;float coeffa30;for (j=i-degree+1;j<=i+1;j+ coeffaj=coeffj;for (k=1;k<=degree;k+ for(j=i+1;j>=i-degree+k+1;j- t1=(knotj+degree-k-u/(knotj+degree-k-knotj-
8、1; t2=1.0-t1;coeffaj=t1*coeffaj-1+t2*coeffaj;return coeffai+1;主函數(shù):void CBView:OnDraw(CDC* pDCCBDoc* pDoc = GetDocument(; ASSERT_VALID(pDoc;/ TODO: add draw code for native data here int k,n;int degree,i,a;int dense=290,l=5;float coeffx=10,40,265,300,400,500,600;float coeffy=20,130,160,90,300,100,300
9、; float points12000,points22000;float knot=0,0,0,0,0,1,2,2,2,2,2;int *point_num; k=5,n=5;/*n+1 個點 */ degree=5;a=0; point_num=&a;for (i=0;i<6;i+ pDC->MoveTo(intcoeffxi,(intcoeffyi; pDC->LineTo (intcoeffxi+1,(intcoeffyi+1;bsp(degree,l,coeffx,knot,dense,points1,point_num;bsp(degree,l,coeffy,knot,dense,points2,point_num;for(i=0;i<2000;i+pDC->SetPixel(intpoints1i,(intpoints2i,RGB(123,123,12
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 豪華別墅裝修委托合同模板
- 石子加工生產(chǎn)合同范本
- 小區(qū)車位權(quán)益合同范本
- 農(nóng)村電力安裝合同范本
- 話劇劇本合同范本
- 農(nóng)場樂園采購合同范本
- 心愿任務(wù)群之許下遠足心愿-一年級語文下冊二單元《我多想去看看》教學(xué)設(shè)計(第一課時)
- 內(nèi)部承包磚合同范本
- 安裝門窗合同范本
- 2025年新版正式員工勞動合同范本
- 日用百貨、食品定點供貨服務(wù)方案
- 高等數(shù)學(xué)全書教案完整版電子教案整本書教案最全單元教學(xué)設(shè)計1-10章全
- DB14∕T 2447-2022 建設(shè)項目環(huán)境影響后評價技術(shù)導(dǎo)則 生態(tài)影響類
- Q∕GDW 12152-2021 輸變電工程建設(shè)施工安全風(fēng)險管理規(guī)程
- 冶金等工貿(mào)企業(yè)安全生產(chǎn)標準化達標信息管理系統(tǒng)[冶金等工貿(mào)企業(yè)安全生產(chǎn)標準化達標信息管理系統(tǒng)](-33)
- 《閱讀與寫作》課程教學(xué)大綱
- 純滯后控制技術(shù)
- 課件使用詳細說明書寫法
- 單位消防安全三自主兩公開一承諾登記表
- 模擬飛行Xsdk的安裝方法
- PCB加工工藝要求說明書經(jīng)典模板
評論
0/150
提交評論