| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1497 人关注过本帖
标题:小船过河追踪动画最佳模型
只看楼主 加入收藏
世事难料
Rank: 1
等 级:新手上路
帖 子:16
专家分:0
注 册:2004-5-3
收藏
 问题点数:0 回复次数:5 
小船过河追踪动画最佳模型

水的流速成抛物线分布,敌船在对岸跑,警船在另一头自动追踪。

大家可以运行一下,欢迎提意见。

头文件应该

#include<math.h>

#include<conio.h>

#include<graphics.h>

#include<stdio.h>

#include<stdlib.h>

#include<time.h>

#include<malloc.h>

#include<string.h>

main() { float X,Y,x,y,U,u,ux,c,d,k,v1,v2,t=0.0001,m,mm; void *p1,*p2; int gd=DETECT,gm; initgraph(&gd,&gm,""); m=sqrt(3); mm=20+6*m;

setcolor(4);/*draw the ship*/ arc(20,228,210,330,12); arc(20,216,240,300,12*m); line(20,216+12*m,20,216); line(20,216,mm,222); line(mm,222,20,228); setfillstyle(1,4); floodfill(20,239,4); floodfill(21,222,4); p1=malloc(imagesize(20-6*m,216,mm,240)); getimage(20-6*m,216,mm,240,p1);

setcolor(14);/*draw the except ship*/ arc(80,68,210,330,12); arc(80,56,240,300,12*m); line(80,56+12*m,80,56); line(80,56,60+mm,62); line(60+mm,62,80,68); setfillstyle(1,14); floodfill(80,79,14); floodfill(81,62,14); p2=malloc(imagesize(80-6*m,56,80+6*m,80)); getimage(80-6*m,56,80+6*m,80,p2);

y=d=160;c=50;u=120;v2=20; do { cleardevice(); clrscr(); if(v2+20>u) break; x=60; X=Y=0; setfillstyle(1,10); bar(0,55,640,242);

outtextxy(240,45,"Ship Catching Mode"); outtextxy(240,260,"red is the catcher"); outtextxy(240,280,"whrite is water"); outtextxy(240,300,"blue is excapter"); coordc(20,240,600,0,600,3); coordc(20,240,180,90,180,3); do{x=x+v2*t; k=atan((y-Y)/(x-X)); v1=(-4*c*Y*Y)/(d*d)+(4*c*Y)/d; ux=(-v1*tan(k)*tan(k)+sqrt(u*u+tan(k)*tan(k)*u*u-tan(k)*tan(k)*v1*v1))/(1+tan(k)*tan(k)); U=sqrt(v1*v1+u*u+2*v1*ux); X=X+U*cos(k)*t; Y=Y+U*sin(k)*t;

putimage(20+X-6*m,216-Y,p1,1); putimage(20+x-6*m,56,p2,1); setcolor(10); putimage(20+X-6*m,216-Y,p1,1); putimage(20+x-6*m,56,p2,1);

putpixel(20+x,240-y,1); putpixel(20+X,240-Y,5); putpixel(20+v1,240-Y,15); if(fabs(Y-y)<=0.01&&fabs(X-x)<=0.01) break;}while(1);

v2+=20; printf("Press any key to continue\nPress Esc to end ");}while(getch()!=27);

closegraph(); }

搜索更多相关主题的帖子: 小船 动画 模型 过河 追踪 
2004-05-04 20:01
tvrc200379
Rank: 1
等 级:新手上路
帖 子:351
专家分:0
注 册:2004-3-30
收藏
得分:0 
好东西啊!

我是灌水天堂的新版主,请新老用户来报道啊 (欢迎来灌水。。。) 哈哈哈。。。。 http://websx.home./bbs/list.asp?boardid=35
2004-05-05 16:33
chengstone
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
帖 子:562
专家分:226
注 册:2004-4-3
收藏
得分:0 

由于楼主的代码有些乱码 与是我给整理了一下 但是经过编译后 有个函数我的win-tc不能识别 就是coordc这个函数 在下面的程序里我把两个coordc函数给/**/注释了 虽然编译通过了 可是执行以后在屏幕上只出现了一个淡灰色的矩形我在后面加了一个getch(); 为了观察结果 可是什么都没有发生 楼上的编译通过了么?

#include<math.h> #include<conio.h> #include<graphics.h> #include<stdio.h> #include<stdlib.h> #include<time.h> #include<malloc.h> #include<string.h> main() { float X,Y,x,y,U,u,ux,c,d,k,v1,v2,t=0.0001,m,mm; void *p1,*p2; int gd=DETECT,gm; initgraph(&gd,&gm,""); m=sqrt(3); mm=20+6*m; setcolor(4);/*draw the ship*/ arc(20,228,210,330,12); arc(20,216,240,300,12*m); line(20,216+12*m,20,216); line(20,216,mm,222); line(mm,222,20,228); setfillstyle(1,4); floodfill(20,239,4); floodfill(21,222,4); p1=malloc(imagesize(20-6*m,216,mm,240)); getimage(20-6*m,216,mm,240,p1); setcolor(14);/*draw the except ship*/ arc(80,68,210,330,12); arc(80,56,240,300,12*m); line(80,56+12*m,80,56); line(80,56,60+mm,62); line(60+mm,62,80,68); setfillstyle(1,14); floodfill(80,79,14); floodfill(81,62,14); p2=malloc(imagesize(80-6*m,56,80+6*m,80)); getimage(80-6*m,56,80+6*m,80,p2); y=d=160;c=50;u=120;v2=20; do { cleardevice(); clrscr(); if(v2+20u) break; x=60; X=Y=0; setfillstyle(1,10); bar(0,55,640,242); outtextxy(240,45,"Ship Catching Mode"); outtextxy(240,260,"red is the catcher"); outtextxy(240,280,"whrite is water"); outtextxy(240,300,"blue is excapter"); /*coordc(20,240,600,0,600,3); coordc(20,240,180,90,180,3); */ do{x=x+v2*t; k=atan((y-Y)/(x-X)); v1=(-4*c*Y*Y)/(d*d)+(4*c*Y)/d; ux=(-v1*tan(k)*tan(k)+sqrt(u*u+tan(k)*tan(k)*u*u-tan(k)*tan(k)*v1*v1))/(1+tan(k)*tan(k)); U=sqrt(v1*v1+u*u+2*v1*ux); X=X+U*cos(k)*t; Y=Y+U*sin(k)*t; putimage(20+X-6*m,216-Y,p1,1); putimage(20+x-6*m,56,p2,1); setcolor(10); putimage(20+X-6*m,216-Y,p1,1); putimage(20+x-6*m,56,p2,1); putpixel(20+x,240-y,1); putpixel(20+X,240-Y,5); putpixel(20+v1,240-Y,15); if(fabs(Y-y)==0.01&&fabs(X-x)==0.01) break;}while(1); v2+=20; printf("Press any key to continue\nPress Esc to end ");}while(getch()!=27); getch(); closegraph(); }


qq:69558139
2004-07-20 13:16
四毛
Rank: 1
等 级:新手上路
帖 子:11
专家分:0
注 册:2004-8-13
收藏
得分:0 
运行不了啊

2004-08-15 22:36
指向指针的指针
Rank: 1
等 级:新手上路
帖 子:339
专家分:0
注 册:2004-8-8
收藏
得分:0 
一片灰白

/sign.png" border="0" onload="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://www./sign.png');}" onmousewheel="return imgzoom(this);" alt="" />
2004-08-18 18:58
fhgo
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2022-11-23
收藏
得分:0 
运行不了
2022-12-05 16:12
快速回复:小船过河追踪动画最佳模型
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.019706 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved