Unit Unit2;
var
Form2: TForm2;
angle,j,k,kx,ky,ra,rb,e,x,y,va,vb,vc,a,t,t2,speed:real;
xc,yc,w,h,xf,n,cc,step:integer; flag:boolean;
implementation
uses Unit1, Unit3;
{$R *.dfm}
procedure TForm2.FormClose(Sender: TObject; var Action: TCloseAction);
begin
form1.close;
end;
procedure TForm2.BitBtn1Click(Sender: TObject);
var rrr:trect; aa,bb,cc:integer; s:string;
begin
// дано
val(form1.edit1.text,ra,cc);
if cc<>0 then ra:=1; val(form1.edit2.text,e,cc);
if cc<>0 then e:=0.0167; val(form1.edit3.text,vc,cc);
if cc<>0 then vc:=0.9856;
t:=360/vc; t2:=t/2; flag:=true;
// вычисляем
va:=vc*sqrt((1+e)/(1-e)); vb:=vc*sqrt((1-e)/(1+e));
a:=(va-vb)/t2; val(edit1.Text,step,cc);
if cc<>0 then step:=1; str(va:3:11,s);
label1.caption:=s; str(vb:3:11,s);
label2.caption:=s; str(vc:3:11,s);
label3.caption:=s; rb:=ra*sqrt(1-e*e);
// графика
w:=image1.Width; h:=image1.Height;
xc:=w div 2; yc:=h div 2;
kx:=ra/(xc-50); ky:=rb/(yc-50);
if kx>ky then k:=(xc-20)/ra else k:=(yc-20)/rb;
timer1.Enabled:=true;
aa:=round(ra*k); bb:=round(rb*k);
image1.Canvas.Brush.Color:=clnavy;
rrr:=rect(0,0,w,h); image1.Canvas.FillRect(rrr);
image1.Canvas.Brush.Color:=clwhite;
rrr:=rect(xc-aa,yc-bb,xc+aa,yc+bb);
image1.Canvas.Ellipse(rrr);
cc:=3; image1.Canvas.Brush.Color:=clnavy;
rrr:=rect(xc-aa+cc,yc-bb+cc,xc+aa-cc,yc+bb-cc);
image1.Canvas.Ellipse(rrr); xf:=round(ra*e*k);
cc:=30; image1.Canvas.Brush.Color:=clyellow;
rrr:=rect(xc+xf+cc,yc+cc,xc+xf-cc,yc-cc);
image1.Canvas.Ellipse(rrr);
cc:=6; image1.Canvas.Brush.Color:=clred;
rrr:=rect(xc-xf+cc,yc+cc,xc-xf-cc,yc-cc);
image1.Canvas.Ellipse(rrr);
rrr:=rect(xc+xf+cc,yc+cc,xc+xf-cc,yc-cc);
image1.Canvas.Ellipse(rrr);
angle:=0; n:=0; speed:=va; j:=pi/180;
end;
procedure TForm2.Timer1Timer(Sender: TObject);
var rrr:trect;s:string;i:integer;
begin
image1.Canvas.MoveTo(xc+xf,yc);
image1.Canvas.pen.Color:=clyellow;
ifangle<360 then image1.Canvas.
LineTo (xc+round(ra*cos(angle*j)*k),
(c-round(rb*sin(angle*j)*k)); for i:=1 to step do
begin
inc(n);
if angle<180 then speed:=speed-a else speed:=speed+a;
angle:=angle+speed; end;
str(speed:3:11,s); label4.Caption:=s;
if angle>=(360-a) then begin timer1.Enabled:=false; flag:=false; end;
cc:=6; image1.Canvas.Brush.Color:=clred;
rrr:=rect(xc-xf+cc,yc+cc,xc-xf-cc,yc-cc);
image1.Canvas.Ellipse(rrr);
rrr:=rect(xc+xf+cc,yc+cc,xc+xf-cc,yc-cc);
image1.Canvas.Ellipse(rrr);end;
procedure TForm2.BitBtn2Click(Sender: TObject);
begin
if flag then timer1.enabled:=not timer1.enabled;
end;
procedure TForm2.BitBtn3Click(Sender: TObject);
begin
form2.Hide; form1.Show;end;
procedure TForm2.BitBtn4Click(Sender: TObject);
begin
form2.Hide; form3.Show;
end;end.
Дата добавления: 2015-09-07; просмотров: 676;