追击问题作战模拟

时间:2014-12-04 17:07:37
【文件属性】:
文件名称:追击问题作战模拟
文件大小:2KB
文件格式:PAS
更新时间:2014-12-04 17:07:37
delphi unit Unit2; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls,Math, TeEngine, Series, ExtCtrls, TeeProcs, Chart; type Tcatchform = class(TForm) lbl1: TLabel; lbl2: TLabel; lbl3: TLabel; lbl4: TLabel; lbl5: TLabel; lbl6: TLabel; lbl7: TLabel; lbl8: TLabel; lbl9: TLabel; lbl10: TLabel; lbl11: TLabel; lbl12: TLabel; btn1: TButton; edt1: TEdit; edt2: TEdit; edt3: TEdit; edt4: TEdit; edt5: TEdit; edt6: TEdit; edt7: TEdit; edt8: TEdit; edt9: TEdit; edt10: TEdit; edt11: TEdit; cht1: TChart; lnsrsSeries1: TLineSeries; lbl13: TLabel; procedure btn1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var catchform: Tcatchform; implementation {$R *.dfm} procedure Tcatchform.btn1Click(Sender: TObject); var LX,LY,HX,HY,LV,HVY,HV,C,X,Y:real; T1,T2,T:real; //T1是越野时间,T2是路上时间 LX1,LY1,a,b,BC,min:real; k:integer; begin HX:=strtofloat(edt1.Text); LX:=strtofloat(edt2.Text); HY:=strtofloat(edt3.Text); LY:=strtofloat(edt4.Text); C:=strtofloat(edt5.Text); HVY:=strtofloat(edt6.Text); HV:=strtofloat(edt7.Text); LV:=strtofloat(edt8.Text); BC:=0; a:=LX; b:=LY; min:=5000; repeat BC:=BC+0.001;//取步长 for k:=1 to 500 do begin a:=LX+k*BC; b:=LY+k*tan(C*pi/180)*BC; //上路点假想 T1:=sqrt(sqr(b-HY)+sqr(a-HX))/HVY; LX1:=LX+LV*cos(C*pi/180)*T1; LY1:=LY+LV*sin(C*pi/180)*T1; if LX1T then begin min:=T; X:=a; Y:=b; cht1.Series[0].AddXY(X,min,'',clred); end; end; until BC>4; edt9.Text:=floattostr(X); edt10.Text:=floattostr(Y); edt11.Text:=floattostr(min); end; end.

网友评论