



下載本文檔
版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、精選優(yōu)質(zhì)文檔-傾情為你奉上/*sutherland_cohen裁剪算法*/#define LEFT 1#define RIGHT 2#define BOTTOM 4#define TOP 8#define XL 150#define XR 350#define YB 150#define YT 300#include "math.h"#include "graphics.h"#include "conio.h"#include "stdio.h" void initialize(void) int graphdri
2、ver; int graphmode; int errorcode; graphdriver=DETECT; initgraph(&graphdriver,&graphmode,"d:tc"); errorcode=graphresult(); if (errorcode!=0) printf("graphics system erreor: %s",grapherrormsg(errorcode); exit(1);main() initialize( ); setcolor(12); line(XL,YT,XR,YT); line(X
3、L,YB,XR,YB); line(XL,YT,XL,YB); line(XR,YT,XR,YB); setcolor(14); draw_ett(); getch(); closegraph();encode(x,y,code)int x,y; int *code; int c;c=0;if(x<XL) c=c|LEFT;else if (x>XR) c=c|RIGHT;if(y<YB) c=c|BOTTOM;else if(y>YT) c=c|TOP;*code=c;return;draw_ett()int x1,x2,y1,y2,x,y; int code1,co
4、de2,code; x1=50; y1=250; x2=400; y2=300;setcolor(1);line(x1,y1,x2,y2);encode(x1,y1,&code1);encode(x2,y2,&code2);while(code1!=0)|(code2!=0) if(code1&code2)!=0) return; code=code1; if(code1=0) code=code2; if(LEFT&code)!=0) x=XL; y=y1+(y2-y1)*(XL-x1)/(x2-x1); else if(RIGHT&code)!=0)
5、 x=XR; y=y1+(y2-y1)*(XR-x1)/(x2-x1); else if(BOTTOM&code)!=0) y=YB; x=x1+(x2-x1)*(YB-y1)/(y2-y1); else if(TOP&code)!=0) y=YT; x=x1+(x2-x1)*(YT-y1)/(y2-y1); if(code=code1) x1=x; y1=y; encode(x,y,&code1);else x2=x; y2=y; encode(x,y,&code2);setcolor(14);line(x1,y1,x2,y2);return;#define
6、LEFT 1#define RIGHT 2#define BOTTOM 4#define TOP 8#define XL 150#define XR 350#define YB 150#define YT 300#include "math.h"#include "graphics.h"#include "conio.h"#include "stdio.h" void initialize(void) int graphdriver; int graphmode; int errorcode; graphdrive
7、r=DETECT; initgraph(&graphdriver,&graphmode,"d:tc"); errorcode=graphresult(); if (errorcode!=0) printf("graphics system erreor: %s",grapherrormsg(errorcode); exit(1);main()int x1,y1,x2,y2,xx,yy,xxx,yyy; initialize();scanf("%d,%d,%d,%d",&x1,&y1,&x2,&a
8、mp;y2);cleardevice();xx=0;yy=0;xxx=0;yyy=0; setcolor(12); line(XL,YT,XR,YT); line(XL,YB,XR,YB); line(XL,YT,XL,YB); line(XR,YT,XR,YB); setcolor(14);draw_ett(x1,y1,x2,y2,&xx,&yy);draw_ett(x2,y2,xx,yy,&xxx,&yyy);line(xx,yy,xxx,yyy);getch();closegraph();encode(x,y,code)int x,y; int *code
9、; int c;c=0;if(x<XL) c=c|LEFT;else if (x>XR) c=c|RIGHT;if(y<YB) c=c|BOTTOM;else if(y>YT) c=c|TOP;*code=c;return;draw_ett(x1,y1,x2,y2,x,y)int x1,x2,y1,y2;int *x,*y;int code1,code2,code;int xx,yy;long d,d1,d2;encode(x1,y1,&code1);encode(x2,y2,&code2);if(code2=0)xx=x2;yy=y2; *x=xx; *y=yy; return;if(code1&code2)!=0) return;do xx=(x1+x2)/2; yy=(y1+y2)/2; encode(xx,yy,&code); d1=(yy-y1)*(yy-y1
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 內(nèi)墻抹灰工程勞務(wù)分包合同
- 勞務(wù)外包員工合同
- 項(xiàng)目會(huì)議記錄與總結(jié)報(bào)告
- 旅游公司客戶行程中意外事件處理協(xié)議
- 礦山環(huán)境治理與生態(tài)恢復(fù)合同
- 智慧城市綜合管理平臺(tái)建設(shè)與運(yùn)營(yíng)方案設(shè)計(jì)
- 環(huán)??萍紕?chuàng)新中心合作協(xié)議
- 個(gè)人茶園承包合同
- 蔬菜基地土地承包合同
- 境外投資項(xiàng)目銀行貸款合同
- 體育科學(xué):田徑考試考試題(三)
- 高考英語(yǔ)經(jīng)常用的七百個(gè)詞匯
- 不定代詞用法總結(jié)及配套練習(xí)題
- 《研學(xué)旅行市場(chǎng)營(yíng)銷》課件-模塊八 研學(xué)旅行促銷策略
- 糖尿病孕婦護(hù)理:案例分析
- (2024年)新版藥品管理法培訓(xùn)課件
- 2022年4月自考00808商法試題及答案含解析
- JGJT280-2012 中小學(xué)校體育設(shè)施技術(shù)規(guī)程
- 《光伏發(fā)電工程安全預(yù)評(píng)價(jià)規(guī)程》(NBT 32039-2017)
- 2024屆吉林省延邊州高三質(zhì)量檢測(cè)(一模)物理試題及答案
- 鐵路扳道員培訓(xùn)課件
評(píng)論
0/150
提交評(píng)論