版權(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)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 多尺度服務(wù)權(quán)衡關(guān)系
- 舒城中考歷史試卷及答案
- 中藥封包護理在疼痛管理中的應(yīng)用
- 代理合同范本
- 廣西工藝美術(shù)研究院有限公司所屬企業(yè)絹麻所2025年12月招聘備考題庫及完整答案詳解1套
- 2025年浙江大學(xué)中國農(nóng)村發(fā)展研究院招聘備考題庫完整答案詳解
- 2026屆山東省膠州市第一中學(xué)等英語高三第一學(xué)期期末調(diào)研模擬試題含解析
- 2026屆北京101中學(xué)語文高三第一學(xué)期期末檢測試題含解析
- 員工培訓(xùn)需求調(diào)查問卷模板
- 2025年生物塑料研發(fā)與生產(chǎn)項目可行性研究報告
- 工程竣工移交單(移交甲方、物業(yè))
- 服裝生產(chǎn)車間流水線流程
- 錢乙完整版本
- 常見的胃腸道疾病預(yù)防
- 2024-2025學(xué)年江蘇省徐州市高一上學(xué)期期末抽測數(shù)學(xué)試題(解析版)
- 新解讀《DL-T 5891-2024電氣裝置安裝工程 電纜線路施工及驗收規(guī)范》新解讀
- 生產(chǎn)部裝配管理制度
- DB31/T 1205-2020醫(yī)務(wù)社會工作基本服務(wù)規(guī)范
- 酒店供貨框架協(xié)議書
- 紡織品的物理化學(xué)性質(zhì)試題及答案
- 高處安裝維護拆除作業(yè)培訓(xùn)
評論
0/150
提交評論