版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、 算法演示1pxpy1px1py1px0.5py1px xM2p1pP=(xp,yp)G1px0.5py1px0.5pypxpypxpypxpypxpypypxpxpy1x1y1x1y圖一圖二x=xc+r cosy=yc+r sin),(yx),(xy),(yx),(yx ),(xy),(yx ),(xy ),(xy22p1P=(x,y) xp xp+1 xp+2ypyp-1yp-2p2MP=(x,y) xp xp+1 xp+2p2Mypyp-1yp-2p1P=(x,y) xp xp+1 xp+2p2Mypyp-1yp-2p1p1P=(x,y) xp xp+1 xp+2p2Mypyp-1yp-
2、2 =d+2(xp-yp)+5P=(x,y) xp xp+1 xp+2p2Mypyp-1yp-2p1void MidpiontCircle(xc,yc,r,color)int xc,yc,r,color; int x,y,d; x=0,y=r,d=1-r; WholeCircle(xc,yc,x,y,color); while(xy) x+; if(d0) d+=2*x+3; else d+=2*(x-y)+5;y-; WholeCircle(xc,yc,x,y,color); void WholeCircle(xc,yc,x,y,color)int xc,yc,x,y,color putix
3、el(xc+x,yc+y,color);圓算法演示橢圓算法演示圓環(huán)腎形x1 y1X2 y2xn ynx1 y1 z1x2 y2 z2 zn yn xn(x1,y1)(x2,y2)(x3,y3)(x4,y4)x1 y1X2 y2X3 y3X4 y4平面圖形dcbaT)0, 0(00dadaTs) , (),(00),(yxdyaxdayx2020524020202002101026201010 x yABCABC10203010203040ABCACB(1)40 x y102030401020304055134020205 . 0002101026201010 xyABCABC(2)1001mx
4、T) , (),(1001),(yxyxyx1001myT) , (),(1001),(yxyxyx10 201020(1)2.對原點(diǎn)對稱變換10010mT) , (),(1001),(yxyxyxAC011045mT) , (),(0110),(yxxyyx011045mT) , (),(0110),(yxxyyx11cbT),(11),(ybxcyxcbyx101cTshx)0)(, (),(101),(cyxycyxcyx 1010264030621201101026201010ABCABCx y,101bTshy)0)(, (),(101),(byxybxxbyxx y50304620
5、10101021101026201010ABCABCx yx ycossinsincosrT) , ()cossin,sincos(cossinsincos),(yxyxyxyx32.2266.1366.2134. 166. 351.1760cos60sin60sin60cos101026201010ABCx yx yABCdcbaT) , (),(),(yxdybxcyaxdcbayxmdbkcaT),()1 ,(mdybxkcyaxmdbkcayxmkTt1001) , (),(1001)1 ,(yxmykxmkyx1mkqdcpbaT1010001mkT12030120201362011
6、020110101261011010010001ABCx yABC20101020ABCABC/* 650597 Lu Runmin exp41.c ROTATE*/# include graphics.h# include math.h# define A 0.0174533void newstar(int p2,int e2,int color)/*int p2,e2,color;*/ int i,m,n,x1,y1,x2,y2; for(i=0;i8;i+) m=ei0-1;n=ei1-1; x1=320+pm0;y1=240-pm1;點(diǎn)號(hào)點(diǎn)號(hào)12345678x0-20-80-20020
7、8020y120200-20-120-20020圖形頂點(diǎn)表起點(diǎn)起點(diǎn)12345678終點(diǎn)23456781圖形連邊表1234567810100011ppyxT1000cossin0sincos2T10100011ypxTp1)cos1 (sinsin)cos1 (0cossin0sincos321ppppyxyxTTTT100100011acT1000cossin0sincos1000)cos()sin(0)sin()cos(2T1000100013T1000)cos()sin(0)sin()cos(4T100100015acT12sin) 12(cos02cos2sin02sin2cos5432
8、1ACACTTTTTT ABBA1cossinsincos0cossin0sincos1000cossin0sincos10100011mlmlmlT10cossin0sincos10100011000cossin0sincos2mlmlTACBACBACBACB14045125351352511515001010130251201011020ABC1401512551352511515001010130251201011020ABC”ABC”ABCsnmkrjihqfedpcbaTjihfedcbanmkrqp sxzy1000000000000jeasT1000010000100001,
9、xoymT1000010000100001, xozmT 1000010000100001, yozmT)1 ,(100000101zyxjihfdcbTsh) 1 , , , () 1 ,(zyxzfyczizybxhzdyx100001000010001)(dTyshx)1 ,(1 ,)(zydyxTzyxyshx100001000100001)(hTzshx)1 ,(1 ,)(zyhzxTzyxzshx100001000010001)(bTxshy)1 ,(1 ,)(zbxyxTzyxxshy100001000100001)(iTzshy)1 ,(1 ,)(zizyxTzyxzshy10
10、0001000010001)(cTxshz)1 ,(1 ,)(cxzyxTzyxxshz10000100010001)(fcTyshz)1 ,(1 ,)(fyzyxTzyxyshz10000cossin00sincos00001xT10000cos0sin00100sin0cosyT1000010000cossin00sincosyT1010000100001nmkT主視圖側(cè)視圖俯視圖斜等測斜二測等軸測正二測正三測投影方向投影平面投影平面法向法向投影平面1000010000000001iT)1 , ,0 , ()1 ,0 ,()1 ,(zxzxTzyxv100d0100001000011000
11、01000090cos90sin0090sin90cos10000100001000001wT1000100000100001d,變換過程為:1d000100001000011000090cos90sin0090sin90cos0000110000100001000013hT1000000010000013d120001201001102001102040110104011004010001020010204010040jD21356789104yxz1200012000110001100401100401100401000100010040100401000010000000001 (Dj)
12、 Tv)(Dj(Dj)110001200013000130040120040110040110001300013004011004011000000001000001DjTDjDjHH1200101200201100301100301100201100101001010030100301001010010010000010001DjTDjDjwwvDjhDjwDjxzcossin0010001000sincos000cos()sin()0000000100sin()cos()00010000100010001cos0sinsin0sin0cos sin000cos00001T整個(gè)形成過程可以用
13、矩陣表示為式子中, 和均取大于0的值。 ( 0.70700.40800.70700.4080000.81600001T 。0.93500.11800.35400.3120000.94300001T123456789101112zyx 頂點(diǎn)表頂點(diǎn)號(hào) x y z 1 0 0 0 2 0 0 200 3 200 0 200 4 0 50 40 5 0 50 40 6 0 50 200 7 200 50 200 8 200 50 40 9 200 150 40 10 0 150 0 11 0 150 0 12 200 150 0邊號(hào) 連邊頂點(diǎn) 1 1 2 2 2 3 3 3 4 4 4 1 5 1 1
14、1 6 11 12 7 12 4 8 5 6 9 6 7 10 7 8 11 8 5 12 5 10 13 10 9 14 9 8 15 9 12 16 10 11 17 3 7 18 2 6 sdddrcccqbbbpaaa321321321321, ,Tp q r1,100001000100001)1 ,(qyzyxqzyx1 , , , 1111zyxqyzqyyqyxzzyx00010zqyxzyx)1,(100010000100011 ,yzprzyxrpzyx)1/()1/()1/(yzpxzzrzpxyyrzpxxx10000100000000010000100010001rqp
15、Tzxoxzo10000100000000011000010001000011010000100001321qdddT1001000000001231qdddq10000100000000011000010001000011000010000cossin00sincosqT10000100cos00sinsin00cosqq100001000000000110000100010000110000cossin00sincos000011000010000cossin00sincosqT1000sincos00cossinsincos0sinsinsinsin0cosqqq凸多邊形凹多邊形p1p2
16、p3p4p5p6p7 圖中多邊形頂點(diǎn)序列為p1 p2 p3 p4 p5 p6 p7。可以根據(jù)這種方法寫出在計(jì)算機(jī)上繪制多邊形的算法: draw_polygon(int N,int pN2) if(N=2) return(); else for(i=1;iN;i+) line(pi0,p i1,pi+10,pi+11); line(p10,p11,pN0,pN1); p1p2p4p3p5s1p1s2p2p3s5S3(s4)Pi+1piPi-1Yi+1YiYi-1Pi+1piPi-1Yi+1YiYi-1p2p1p3p4p5p6p7p8p9x2x1x3x4x5x6 梯形的兩底邊分別在y=yk和y=y
17、k+1兩條掃描線上,腰在多邊形p的邊上或在顯示屏幕的邊界上。Yk+1ykABxi xi+176543210 1 2 3 4 5 6 7 8r1 r2 r3 r4r5 r6將種子象素壓入棧;當(dāng)棧非空時(shí) a.從堆棧彈出一個(gè)象素;b.將該象素置成所要求的色彩值;c.檢查當(dāng)前每個(gè)象素鄰接的四連接象素是否是邊界色或已置成所要求的色彩值,若是則返回,否則將該象素壓入堆棧后再回到。76543210 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 9 1012345678910AcBDHGFES1SS2XYp1p2p3p4p0(x0,y0)sincos:01011ayyaxxP)sin()
18、cos(:12122ayyaxxP)1(sin()1(cos(:23233iayyiaxxP# includegraphics.h# includemath.hvoid polygon(x0,y0,a,n,af)int x0,y0,a,n;float af;int x,y,i;float dtheta,theta;if(n3) return;dtheta=6.28318/n;theta=af*0.0174533;moveto(x0,y0);x=x0;y=y0;for(i=1;in;i+)x=x+a*cos(theta);sincos0101:1RyyRxxP)sin()cos(0202:2Ry
19、yRxxP)sin()cos(00:iRyyiRxxPiii# includegraphics.h# includemath.hvoid polygonc();void block();main()int i,j,a,length,n,theta, x=100,y=350;int gdriver=DETECT,gmode;printf(Input length ,n,theta(for example 320,240,5):);scanf(%d,%d,%d, &length,&n,&theta);initgraph(&gdriver,&gmode,c:t
20、c);p3p5p1p7p9p4p2p6p8p10五角形六角形p2p1o21121sinsinpoppopRR21121sinsinpoppopRRRNNNNpoppopRR)2/) 2sin()2/) 4sin(sinsin21121poly(x0,y0,r,n,af)if(n=4) return;th=3.141592653/n;af1=af*0.0164533;ct=cos(th);st=sin(th);ca=cos(af1);sa=sin(af1);xs=x0+r*ca;ys=y0+r*sa;moveto(xs,ys);r1=r*sin(n-4)*th/2)/sin(n-2)*th/2)
21、;for(i=1;i0)xp=(xa+xb)/2;yp=(ya+yb)/2;xq=(xb+xc)/2;yq=(yb+yc)/2;xr=(xc+xa)/2;yr=(yc+ya)/2;moveto(xp,yp);lineto(xq,yq);lineto(xr,yr);lineto(xp,yp);tria(xa,ya,xp,yp,xr,yr,n-1);tria(xb,yb,xq,yq,xp,yp,n-1);tria(xc,yc,xr,yr,xq,yq,n-1);方塊旋轉(zhuǎn)# includegraphics.h# includemath.hvoid polygonc();void block();mai
22、n()int i,j,a,length,n,theta, x=100,y=350;int gdriver=DETECT,gmode;printf(Input length,n,theta (for example 320,240,5):);scanf(%d,%d,%d, &length ,&n, &theta);initgraph(&gdriver,&gmode,c:tc);動(dòng)畫1# includegraphics.h# define TIME 1000void moon(x,y,r) int x,y,r; setcolor(WHITE); arc(x,
23、y,-120,120,r); arc(x-0.5*r,y,-90,90,0.87*r); setfillstyle(SOLID_FILL,WHITE); floodfill(x+0.5*r,y,WHITE); return();void car(dx,color,nu,p) int dx,color,nu,*p;動(dòng)畫2# includegraphics.h# define TIME 100void moon(x,y,r) int x,y,r; setcolor(WHITE); arc(x,y,-120,120,r); arc(x-0.5*r,y,-90,90,0.87*r); setfills
24、tyle(SOLID_FILL,WHITE); floodfill(x+0.5*r,y,WHITE); return;void car(dx,color,nu,p) int dx,color,nu,*p;動(dòng)畫3# includegraphics.h# includestdio.h# includealloc.h# includedos.h# define TIME 100main()int pcar92=5,350,90,350,90, 335,70,335,65, 320,25,320,20, 335,5,335,5,350;int road52=0,360,0,479,639, 479,6
25、39,360,0,360;int sky52=10,40,10,72,455, 72,455,40,10,40;int i,carcolor=RED;void *carsize,*moonsize;xlx xrybyyt acbADBfCe算法演示A0000Bw1 w2w4w3(x,y)00011001 1000 10100001 窗口 00100101 0100 0110p7p5p6p8p3p41000001000010100p2p1p3p4p1p2p3(x2,y2)(x1,y1)wxl wxr102345678wxlx1 wxrwyb y1 wyt算法演示p1p2p1p1p1p2p2p2p
26、2p2p1p1abcdepmpm (a) (b) (c)p1p2p3p4p5p6p7p8p9左邊裁剪頂邊裁剪右邊裁剪p4p1p9p8p7p2p3p5p6Q1Q4Q5Q6Q7Q8Q9Q10Q2Q3(1)輸出l1和P2 (2)輸出P3 (3)輸出l2 (4)無輸出 線段起點(diǎn)S和終點(diǎn)E與裁剪邊的四種位置關(guān)系p4p3E=p2S=p1可見一側(cè)l1E=p3p1s=p2可見一側(cè)l1p3s=p4E=p1p2可見一側(cè)l2p2S=p3p4p1可見一側(cè)l2演示演示1演示演示2演示演示3ABDCEF fgecbaohaBCDEFh xxyyzo xyXy xy WC NDC DCWytWyb(Wxr,Wyt)WxlW
27、xr(Wxl,Wyb)ABCabcWXL=100 WXR=500WXL=100 WXR=300(100,100)(100,100)WYB=100(500,500)WYT=500VYT=300VYB=100501002110025010021100121100500100300211005001003002121YBYBXLXLYBYTYBYTXLXRxlxrWKVCWKVCWWVVKWWvvk VBYBWYBYTYBYTVXLXLWXLXRXLXRVYWYWWVVYVWXWWVVX)()(;21YBYTYBYTXLXRXLXRWWVVKWWVVK;22;11YBYBXLXLWKVCWKVC則0
28、21020001cckkAt=1001143242321ppp void parspl(p,n,k,e)int p2,n,k,e;int x,y,i,j,m;float t1,t2,t3,t,a,b,c,d;if(e=1)m=n;p00=p10;p01=p11;pn+10=pn0;pn+11=pn1;elsem=n+1;p00=pn0;niniittBPtP0,)10()()()(,tBni(1)ininittinintB)1 ()!( !)(,000) 01 (0!1!) 0(PPnnPnnnnPPnnP0) 11 (1!1!) 1 ((2))()()1 ()!1( !)!1()1 ()!(
29、)!1()!1()1 ()()1 ()!( !)(1,1, 11111,tBtBnttininttininnttinttiinintBniniiniiniiniinini)()()( 1,1, 110tBtBpntPnininii)()0( 01PPnp)() 1 ( 1nnPPnp(3)) 10 ()1 (2)1 ()(22102tPtPttPttP(4)21020010221211)(pPPtttP)(,tBni22 , 021)(tttB22, 12)(tttB22,2)(ttB)P-2(P=P=P010)(t0)P-2(P=P=P121)(t2)(212141214121201210PPPPPPPP0P2P1PPm,0( )nikk nkpFt!1nknjnnjjjkntC01)() 1(。220,2301( )( 1)(2)2!jjjFtCtj22221 3!3!3!1(2)(1)(1)2 3!2!2!2tttt21,221,21( )( 221)21( )2FtttFtt0,21,212,22( )( )( )( )iiiP tFt PFt PFt P2,200212( )( )121112202110kkkP tB FtBttBB012121( )1110BP
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 給女老板一份結(jié)婚協(xié)議書范文
- 北京小區(qū)樣板間合作協(xié)議書范文
- 產(chǎn)品經(jīng)理個(gè)人年終總結(jié)
- 學(xué)校普通話培訓(xùn)
- 動(dòng)脈瘤栓塞術(shù)術(shù)后護(hù)理
- 農(nóng)業(yè)合作社決策機(jī)制與制度建設(shè)
- 示范性綜合實(shí)踐活動(dòng)
- 各個(gè)班組安全培訓(xùn)試題【培優(yōu)B卷】
- 新入員工安全培訓(xùn)試題(一套)
- 公司級員工安全培訓(xùn)試題(考題)
- 煤礦安全知識(shí)競賽風(fēng)險(xiǎn)題(120道題)備課講稿
- GB/T 3811-1983起重機(jī)設(shè)計(jì)規(guī)范
- 全國高等醫(yī)學(xué)院校臨床教學(xué)基地評審評分標(biāo)準(zhǔn)
- 射線防護(hù)工程施工工法
- 抗菌藥物科普小常識(shí)
- 小學(xué)四年級下冊綜合實(shí)踐活動(dòng).二十四節(jié)氣-(37張)ppt
- 鼻通氣功能檢查
- MES技術(shù)及其應(yīng)用-西門子MES剖析課件
- 搶救車藥品交接本
- 體育說課教學(xué)課件
- 畫鼻子游戲課件
評論
0/150
提交評論