




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、C语言动画程序#include <math.h> #include <stdio.h> #include <graphics.h> #include <dos.h> #define pi 3.1415926535 double ca3mm1(double m1,double m2); double ca3fm1(double cosine,double sine); double ca5fm2(double a6m,double a5m,double a4m,double a4f,int shang); double ca6fm2(double
2、a4m ,double a4f,double a5m , double a5f); char inbox(int x,int y,int x1,int y1); char buf(); main() double m=3.0; double xo=100.0,yo=200.0,a1=30.0,t1=pi; double xc=xo+m*a1,yc=yo; double a2=8.0,a3,a4=25.0,a5=30.0,a6=20.0,a7=35.0; double t2,t3,t4,t5,t6,t7; double xo1=xo+m*150,yo1=yo; double xc1=xo1-m*
3、a1,yc1=yo1; double i,j,k; double l1; double n=116.1,nt; initscreen(); setfillstyle(SOLID_FILL,DARKGRAY); bar(0,0,640,480); mybutton(10,10,"BEGIN",1,0); mybutton(500,10,"EXIT",1,0); line(0,69,640,69); mouseinit(); changemousecross(); setmousexy(320,20); mouseshow(); setmousearea(0
4、,0,640,60); do if(inbox(10,10,70,26)&&button()=1) mousehide(); mybutton(10,10,"BEGIN",0,0); mouseshow(); mousehold(); mousehide(); mybutton(10,10,"BEGIN",1,7); mouseshow(); break; if(inbox(500,10,555,26)&&button()=1) mousehide(); mybutton(500,10,"EXIT",0
5、,0); mouseshow(); mousehold(); mousehide(); mybutton(500,10,"EXIT",1,7); mouseshow(); exit(0); if(buf()=56) for(i=0;i<10000;i+) switch (buf() case 18: mousehide(); mybutton(500,10,"EXIT",0,0); mouseshow(); delay(4000); mousehide(); mybutton(500,10,"EXIT",1,7); mouses
6、how(); exit(0); case 48: mousehide(); mybutton(10,10,"BEGIN",0,0); mouseshow(); delay(4000); mousehide(); mybutton(10,10,"BEGIN",1,7); mouseshow(); goto run; default:break; while(1); run: drawjijia(xo,yo,1); drawjijia(xc,yc,1); drawjijia(xo1,yo1,1); drawjijia(xc1,yc1,1); setwrite
7、mode(1); do for(i=0;i<360.0;i+=1.0) t2=i; a3=ca3mm1(a1*cos(t1)+a2*cos(t2*pi/180.0),a1*sin(t1)+a2*sin(t2*pi/180.0); t3=ca3fm1(a1*cos(t1)+a2*cos(t2*pi/180.0),a1*sin(t1)+a2*sin(t2*pi/180.0); a4=a3; t4=t3; t5=ca5fm2(a6,a5,a4,t4,0); t6=ca6fm2(a4,t4,a5,t5); t7=t6-90.0; l1=xc1-xc-2*m*a7*cos(t7*pi/180);
8、nt=(asin(l1/2/(n/2)*180/pi)-90.0; drawline(xo,yo,a2,t2,m,LIGHTGRAY); drawline(xo+m*a2*cos(t2*pi/180),yo-m*a2*sin(t2*pi/180),a5,t5,m,LIGHTGRAY); drawline(xc,yc,a6,t6,m,LIGHTGRAY); drawline(xc,yc,a7,t7,m,LIGHTGRAY); drawline1(xo1,yo1,a2,t2,m,LIGHTGRAY); drawline1(xo1+m*a2*cos(180-t2)*pi/180),yo1-m*a2*
9、sin(180-t2)*pi/180),a5,t5,m,LIGHTGRAY); drawline1(xc1,yc1,a6,t6,m,LIGHTGRAY); drawline1(xc1,yc1,a7,t7,m,LIGHTGRAY); for(j=-1;j<20;j+) drawline(xc+m*a7*cos(t7*pi/180),(yc-m*a7*sin(t7*pi/180)-j*n*sin(nt*pi/180),n,nt,1.0,GREEN); drawline1(xc1-m*a7*cos(t7*pi/180),(yc1-m*a7*sin(t7*pi/180)-j*n*sin(nt*p
10、i/180),n,nt,1.0,DARKGRAY); delay(300); drawline(xo,yo,a2,t2,m,LIGHTGRAY); drawline(xo+m*a2*cos(t2*pi/180.0),yo-m*a2*sin(t2*pi/180.0),a5,t5,m,LIGHTGRAY); drawline(xc,yc,a6,t6,m,LIGHTGRAY); drawline(xc,yc,a7,t7,m,LIGHTGRAY); drawline1(xo1,yo1,a2,t2,m,LIGHTGRAY); drawline1(xo1+m*a2*cos(180-t2)*pi/180),
11、yo1-m*a2*sin(180-t2)*pi/180),a5,t5,m,LIGHTGRAY); drawline1(xc1,yc1,a6,t6,m,LIGHTGRAY); drawline1(xc1,yc1,a7,t7,m,LIGHTGRAY); for(j=-1;j<20;j+) drawline(xc+m*a7*cos(t7*pi/180),(yc-m*a7*sin(t7*pi/180)-j*n*sin(nt*pi/180),n,nt,1.0,GREEN); drawline1(xc1-m*a7*cos(t7*pi/180),(yc1-m*a7*sin(t7*pi/180)-j*n
12、*sin(nt*pi/180),n,nt,1.0,DARKGRAY); setwritemode(0); if(inbox(500,10,555,26)&&button()=1) mousehide(); mybutton(500,10,"EXIT",0,0); mouseshow(); mousehold(); mousehide(); mybutton(500,10,"EXIT",1,7); mouseshow(); exit(0); if(buf()=56) for(k=0;k<10000;k+) switch (buf()
13、case 18: mousehide(); mybutton(500,10,"EXIT",0,0); mouseshow(); delay(4000); mousehide(); mybutton(500,10,"EXIT",1,7); mouseshow(); exit(0); default:break; setwritemode(1); while(1); drawline(double xo,double yo,double mo,double fujiao,double m,int color) double x,y; x=(xo+m*mo*c
14、os(fujiao*pi/180); y=(yo-m*mo*sin(fujiao*pi/180); setcolor(color); line (xo,yo,x,y); drawline1(double xo,double yo,double mo,double fujiao,double m,int color) double x,y; x=(xo-m*mo*cos(fujiao*pi/180); y=(yo-m*mo*sin(fujiao*pi/180); setcolor(color); line (xo,yo,x,y); drawjijia(double x,double y,int
15、shang) setcolor(RED); if (shang=1) circle(x,y,3); line(x-3.0,y+3.0,x-15.0,y+20.0); moveto(x-15,(int)(y+20); lineto(int)(x+15),(int)(y+20); moveto(int)(x+15),(int)(y+20); lineto(x+3,y+3); setcolor(RED); if (shang=0) circle(int)x,(int)y,3); line (x-3,y-3,x-15,y-20); moveto(x-15,y-20); lineto(x+15,y-20
16、); moveto(x+15,y-20); lineto(x+3,y-3); double ca3mm1(double m1,double m2) double temp; temp = sqrt(m1*m1 + m2*m2); return(temp); double ca3fm1(double cosine,double sine) float temp; if (sine > 0 && cosine > 0) temp = atan(sine / cosine) * 180 / pi; if (sine > 0 && cosine <
17、; 0) temp = (atan(sine / cosine) + pi) * 180 / pi; if (sine < 0 && cosine < 0) temp = (atan(sine / cosine) + pi) * 180 / pi; if (sine < 0 && cosine > 0) temp = (atan(sine / cosine) + 2 * pi) * 180 / pi; return(temp); double ca5fm2(double a6m,double a5m,double a4m,double a
18、4f,int shang) double temp,sine1,cosine1; cosine1 = (a6m *a6m - a4m *a4m - a5m*a5m) / (2 * a4m * a5m); sine1 = sqrt(1 - cosine1 *cosine1); if (shang=0) sine1 = sine1*(-1); if (sine1 > 0 && cosine1 > 0) temp = a4f + (atan(sine1 / cosine1) * 180 / pi); if (sine1 > 0 && cosine1
19、< 0) temp = a4f + (atan(sine1 / cosine1) + pi) * 180 / pi); if (sine1 < 0 && cosine1 < 0) temp = a4f + (atan(sine1 / cosine1) + pi) * 180 / pi); if (sine1 < 0 && cosine1 > 0) temp = a4f + (atan(sine1 / cosine1) + 2 * pi) * 180 / pi); return(temp); double ca6fm2(double a4m ,double a4f,double a5m , double a5f) double
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年安全生产事故案例考试题含答案集
- 2025年安全员C证复审核心题库题
- 2025年会计类司法鉴定人助理笔试模拟题库
- 2025年安全管理面试题库及答案解析大全
- 2025年人力资源管理师职业能力认证考试试题及答案解析
- 2025年旅游商品经营管理师资格认证试题及答案解析
- 2025年农业生态修复技术项目规划技术员招聘面试题与答案
- 2025年宠物行业初级管理面试题
- 2025年计算机网络工程师资格认证考试试题及答案解析
- 2025年设备使用安全知识竞赛题库
- 腰椎间盘突出症的中医治疗及护理课件
- 安徽省合肥市一中、六中、八中2024届数学高一上期末学业质量监测模拟试题含解析
- 电子对抗原理与技术-计算题参考答案
- 外研版初中英语单词总表(7~9)年级
- 大众文化概论-课件
- 商业装修手册
- 医院信息互联互通化成熟度测评
- 股票k线图入门图解
- GB/T 15812.1-2005非血管内导管第1部分:一般性能试验方法
- 无轨运输安全操作规程
- 专升本英语统考试翻译技巧课堂教学课件2
评论
0/150
提交评论