全文预览已结束
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
/*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 graphdriver; 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(XL,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(xXR) c=c|RIGHT;if(yYT) c=c|TOP;*code=c;return;draw_ett()int x1,x2,y1,y2,x,y; int code1,code2,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) 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 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; graphdriver=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,&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; int c;c=0;if(xXR) c=c|RIGHT;if(yYT) 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
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 无人机驾驶证培训考试试题及答案
- 2025年建筑施工工程师执业考核试题及答案
- 2025年房地产经纪合同格式范文
- 财务与分析上海杉达学院
- 2025年春季教师资格证考试真题回顾与解析
- 2022年投资项目管理师之宏观经济政策能力测试试卷A卷附答案
- 2025年市场需求分析与预测知识普及试题及答案解析
- 2025 年下半年中式烹调师职业技能等级考试题库及答案
- 2025年河北省邢台市桥东区保安员招聘考试题库附答案解析
- 2023年四川省公务员考试行政职业能力测验真题
- 2024年黑龙江大学招聘笔试真题及答案
- 保密法培训课件
- 胸痛健康知识宣教要点
- 初三语文老师家长会课件
- 2025年党史党建知识测试题库100题(含标准答案)
- 污水管网深基坑钢板桩支护施工方案
- 施工领域排查安全隐患简报
- 小米发展历程
- 2025-2030年中国肠易激综合征治疗药物行业市场现状分析及竞争格局与投资发展研究报告
- 云南保安证考试题及答案
- 2024年中考历史试题分类汇编:世界近代史(原卷版+解析)
评论
0/150
提交评论