unit Un_1; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, math, Spin, Menus, ComCtrls; type TForm1 = class(TForm) Image1: TImage; Button1: TButton; Label1: TLabel; Label2: TLabel; Label5: TLabel; SaveDialog1: TSaveDialog; Button2: TButton; Button3: TButton; SpinEdit1: TSpinEdit; SpinEdit2: TSpinEdit; SpinEdit5: TSpinEdit; SpinEdit6: TSpinEdit; Label6: TLabel; Label8: TLabel; Label9: TLabel; MainMenu1: TMainMenu; N1: TMenuItem; N2: TMenuItem; N3: TMenuItem; N4: TMenuItem; N7: TMenuItem; N9: TMenuItem; N10: TMenuItem; Image4: TImage; Button4: TButton; TrackBar1: TTrackBar; Label7: TLabel; Image3: TImage; Label11: TLabel; N5: TMenuItem; TrackBar2: TTrackBar; TrackBar3: TTrackBar; TrackBar4: TTrackBar; Button5: TButton; Image5: TImage; Image6: TImage; Image7: TImage; Timer1: TTimer; Button6: TButton; Timer2: TTimer; Button7: TButton; Image2: TImage; Image8: TImage; Label10: TLabel; Image9: TImage; Image10: TImage; Image11: TImage; Timer3: TTimer; Memo1: TMemo; Button8: TButton; Label12: TLabel; Image12: TImage; Image13: TImage; Label13: TLabel; Image14: TImage; Label14: TLabel; GroupBox1: TGroupBox; TrackBar5: TTrackBar; Label3: TLabel; Label4: TLabel; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure Button3Click(Sender: TObject); procedure FormCreate(Sender: TObject); procedure N7Click(Sender: TObject); procedure N2Click(Sender: TObject); procedure N3Click(Sender: TObject); procedure N4Click(Sender: TObject); procedure N9Click(Sender: TObject); procedure N10Click(Sender: TObject); procedure Image4Click(Sender: TObject); procedure Button4Click(Sender: TObject); procedure Image1Click(Sender: TObject); procedure TrackBar1Change(Sender: TObject); procedure Button5Click(Sender: TObject); procedure N5Click(Sender: TObject); procedure Image1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); procedure Timer1Timer(Sender: TObject); procedure Button6Click(Sender: TObject); procedure Timer2Timer(Sender: TObject); procedure Button7Click(Sender: TObject); procedure N6Click(Sender: TObject); procedure Timer3Timer(Sender: TObject); procedure Button8Click(Sender: TObject); procedure TrackBar3Change(Sender: TObject); procedure TrackBar4Change(Sender: TObject); procedure TrackBar2Change(Sender: TObject); procedure TrackBar5Change(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; Mouse_x,Mouse_y,a,a1,a2,i1,i2,x0:integer; implementation {$R *.DFM} procedure TForm1.Button1Click(Sender: TObject); Const t=0.5; Var Vx0,Vy0,Vx,Vy,Vc,Vs,x,y,x1,y1,xx,yy,xx1,yy1,z1,z2,a0,b0,K,Cs,Sn:real; a,b,c,d,i,p:integer; Begin Image1.Canvas.Brush.Color:=ClWhite; Image1.Canvas.Rectangle(-10,-10,810,610); Image1.Canvas.Pen.Width:=1; Image1.Canvas.Pen.Color:=clBlack; Image1.Canvas.MoveTo(400,0); Image1.Canvas.LineTo(400,600); Image1.Canvas.MoveTo(0,300); Image1.Canvas.LineTo(800,300); a:=abs(Round(spinedit1.value)); b:=abs(Round(spinedit2.value)); d:=abs(Round(spinedit5.value)); {Vx0:=spinedit3.value; Vy0:=spinedit4.value; } Vx0:=cos(trackbar5.Position*5/57.3); Vy0:=sin(trackbar5.Position*5/57.3); if ((Vx0=0) and (Vy0=0)) then begin Vx0:=4; Vy0:=3; spinedit1.value:=4; spinedit1.value:=3; end; Vc:=-Vx0/sqrt(sqr(Vx0)+sqr(Vy0)); Vs:=Vy0/sqrt(sqr(Vx0)+sqr(Vy0)); Image1.Canvas.Pen.Width:=2; Image1.Canvas.Pen.Color:=Clblue; Image1.Canvas.MoveTo(round(400+a*Vc),round(300-a*Vs)); For i:=-a to +a do begin x:=-i*Vc+b*sqrt(1-sqr(i/a))*Vs; y:=-i*Vs-b*sqrt(1-sqr(i/a))*Vc; Image1.Canvas.LineTo(round(400+x),round(300-y)); end; For i:=a downto -a do begin x:=-i*Vc-b*sqrt(1-sqr(i/a))*Vs; y:=-i*Vs+b*sqrt(1-sqr(i/a))*Vc; Image1.Canvas.LineTo(round(400+x),round(300-y)); end; Image1.Canvas.Pen.Color:=ClRed; p:=2*d;{d*2;round(1152/d);} d:=round(1152/p)-1; If a<>b then begin c:=abs(sqr(a)-sqr(b)); a0:=(1+sqr(a+b)/c)/2; b0:=(1-sqr(a+b)/c)/2; For i:=1-p to p do if trunc(18/d)<>i then begin if Vx0=0 then begin x:=d*i; y:=-700*Vs; end else if Vy0=0 then begin x:=700*Vc; y:=d*i; end else begin x:=-d*i*abs(Vx0)/Vx0+700*Vc; y:=d*i*abs(Vy0)/Vy0-700*Vs; end; while ((x>-1000) and (x<1000) and (y>-1000) and (y<1000)) do begin yy:=2*x*y; xx:=sqr(x)-sqr(y)-c; K:=sqrt(sqr(xx)+sqr(yy)); if y<0 then Sn:=-sqrt((1-xx/k)/2) else Sn:=sqrt((1-xx/k)/2); if x<0 then Cs:=-sqrt((1+xx/k)/2) else Cs:=sqrt((1+xx/k)/2); K:=sqrt(K); z1:=(x*Cs+y*Sn)/K; z2:=(y*Cs-x*Sn)/K; Vx:=Vx0*a0+Vx0*b0*z1+Vy0*a0*z2; Vy:=Vy0*b0+Vy0*a0*z1-Vx0*b0*z2; x1:=x+Vx*t; y1:=y+Vy*t; xx:=-x*Vc+y*Vs; yy:=-x*Vs-y*Vc; xx1:=-x1*Vc+y1*Vs; yy1:=-x1*Vs-y1*Vc; if ((xx>-700) and (xx<700) and (yy>-700) and (yy<700)) then begin Image1.Canvas.MoveTo(round(400+xx),round(300-yy)); Image1.Canvas.LineTo(round(400+xx1),round(300-yy1)); end; x:=x1; y:=y1; if sqr(x/a)+sqr(y/b)<=1 then x:=801; if sqr(Vx)+sqr(Vy)<1E-5 then x:=801; end; end; end else For i:=1-p to p do if trunc(18/d)<>i then begin if Vx0<0 then x:=799 else x:=-799; y:=18-i*d; if Vx0<0 then Vx0:=-sqrt(sqr(Vx0)+sqr(Vy0)) else Vx0:=sqrt(sqr(Vx0)+sqr(Vy0)); Vy0:=0; while ((x>-1000) and (x<1000) and (y>-1000) and (y<1000)) do begin yy:=2*x*y; xx:=sqr(x)-sqr(y); K:=(sqr(xx)+sqr(yy)); Vx:=Vx0-a*a*Vx0*xx/K-a*a*Vy0*yy/K; Vy:=Vy0-a*a*Vx0*yy/K+a*a*Vy0*xx/K; x1:=x+Vx*t; y1:=y+Vy*t; if ((x>-500) and (x<500) and (y>-500) and (y<500)) then begin Image1.Canvas.MoveTo(round(400+x),round(300-y)); Image1.Canvas.LineTo(round(400+x1),round(300-y1)); end; x:=x1; y:=y1; if sqr(x/a)+sqr(y/a)<=1 then x:=801; if sqr(Vx)+sqr(Vy)<1E-5 then x:=801; end; end; if trackbar5.Position=0 then begin image1.Canvas.TextOut(400-trunc(a/2),305,'a'); image1.Canvas.TextOut(405,300-trunc(b/2+7),'b'); end; if (trackbar5.Position=18) or (trackbar5.Position=-18) then begin image1.Canvas.TextOut(400-trunc(b/2),305,'b'); image1.Canvas.TextOut(405,300-trunc(a/2+7),'a'); end; Image1.Canvas.Brush.Color:=ClWhite; Image1.Canvas.pen.Color:=Clblack; Image1.Canvas.Pen.Width:=1; Image1.Canvas.Rectangle(0,570,395,600); image1.Canvas.TextOut(10,573,'Параметры : '); image1.Canvas.TextOut(130,573,'a = '+inttostr(a)); image1.Canvas.TextOut(200,573,'b = '+inttostr(b)); image1.Canvas.TextOut(270,573,'n = '+inttostr(d)); image1.Canvas.TextOut(330,573,'A = '+inttostr(Trackbar5.Position*5)); End; procedure TForm1.Button2Click(Sender: TObject); begin i1:=0; timer1.Enabled:=true; a:=abs(Round(spinedit6.value)); a1:=a; button6.Visible:=true; end; procedure TForm1.Button3Click(Sender: TObject); begin i2:=1; timer2.Enabled:=true; a2:=abs(Round(spinedit6.value)); button6.Visible:=true; x0:=-400+a2; button7.Visible:=false; End; procedure TForm1.FormCreate(Sender: TObject); begin i1:=0;i2:=0; image1.Canvas.Rectangle(-1,-1,1000,1000); //n6.Enabled:=false; image1.Canvas.Font.Size:=14; image4.Canvas.Font.Size:=14; label11.Caption:='= '+inttostr(trackbar1.position); end; procedure speed(x,y:real;var Vxx,Vyy:real); var a,b:integer;Vx,Vy,z1,z2,Sn,Cs,K,c,a0,b0,Vx0,Vy0,Vs,Vc:real; begin a:=abs(Round(form1.spinedit1.value)); b:=abs(Round(form1.spinedit2.value)); //Vx0:=form1.spinedit3.value; //Vy0:=form1.spinedit4.value; Vx0:=5*cos(form1.trackbar5.Position*5/57.3); Vy0:=5*sin(form1.trackbar5.Position*5/57.3); Vc:=-Vx0/sqrt(sqr(Vx0)+sqr(Vy0)); Vs:=Vy0/sqrt(sqr(Vx0)+sqr(Vy0)); c:=abs(sqr(a)-sqr(b)); a0:=(1+sqr(a+b)/c)/2; b0:=(1-sqr(a+b)/c)/2; K:=sqrt(sqr(sqr(x)-sqr(y)-c)+sqr(2*x*y)); if y<0 then Sn:=-sqrt((1-(sqr(x)-sqr(y)-c)/k)/2) else Sn:=sqrt((1-(sqr(x)-sqr(y)-c)/k)/2); if x<0 then Cs:=-sqrt((1+(sqr(x)-sqr(y)-c)/k)/2) else Cs:=sqrt((1+(sqr(x)-sqr(y)-c)/k)/2); K:=sqrt(K); z1:=(x*Cs+y*Sn)/K; z2:=(y*Cs-x*Sn)/K; Vx:=Vx0*a0+Vx0*b0*z1+Vy0*a0*z2; Vy:=Vy0*b0+Vy0*a0*z1-Vx0*b0*z2; Vxx:=-Vx*Vc+Vy*Vs; Vyy:=-Vx*Vs-Vy*Vc; end; procedure TForm1.N7Click(Sender: TObject); begin memo1.Visible:=true; button8.Visible:=true; showmessage('Pre-release build v 0.99.97 - RiaSoft (C) 10.06.2007'); end; procedure TForm1.N2Click(Sender: TObject); begin image1.Canvas.Rectangle(-1,-1,1000,1000); groupbox1.visible:=true; n2.Checked:=true; n3.Checked:=false; n4.Checked:=false; n5.Checked:=false; button1.Visible:=true; button2.Visible:=false; button3.Visible:=false; button5.Visible:=false; button6.Visible:=false; button7.Visible:=false; ////////////////// image12.Visible:=false; image13.Visible:=false; image14.Visible:=false; label12.Visible:=false; label13.Visible:=false; label14.Visible:=false; ////////////////// trackbar2.Visible:=false; trackbar3.Visible:=false; trackbar4.Visible:=false; image5.Visible:=false; image6.Visible:=false; image7.Visible:=false; ////////////////// button4.Visible:=true; ///////////// spinedit1.Enabled:=true; spinedit2.Enabled:=true; spinedit5.Enabled:=true; spinedit6.Enabled:=false; ///////////////////// label7.Visible:=true; label8.Visible:=true; label9.Visible:=true; label4.Visible:=false; end; procedure TForm1.N3Click(Sender: TObject); begin trackbar5.Position:=0; groupbox1.visible:=false; image3.Visible:=false; label11.Visible:=false; image1.Visible:=true; image4.Visible:=false; n5.Checked:=false; spinedit6.MaxValue:=200; image1.Canvas.Rectangle(-1,-1,1000,1000); n2.Checked:=false; n3.Checked:=true; n4.Checked:=false; button1.Visible:=false; button2.Visible:=true; button3.Visible:=false; button5.Visible:=false; button6.Visible:=false; button7.Visible:=false; ////////////////// image12.Visible:=false; image13.Visible:=false; image14.Visible:=false; label12.Visible:=false; label13.Visible:=false; label14.Visible:=false; ////////////////// ////////////////// trackbar2.Visible:=false; trackbar3.Visible:=false; trackbar4.Visible:=false; image5.Visible:=false; image6.Visible:=false; image7.Visible:=false; ////////////////// ///////////// button4.Visible:=false; trackbar1.Visible:=false; ////////////// label4.Visible:=false; label7.Visible:=false; label8.Visible:=false; label9.Visible:=false; /////////////// spinedit1.Enabled:=false; spinedit2.Enabled:=false; spinedit5.Enabled:=false; spinedit6.Enabled:=true; end; procedure TForm1.N4Click(Sender: TObject); begin groupbox1.visible:=false; trackbar5.Position:=18; image3.Visible:=false; label11.Visible:=false; image1.Visible:=true; image4.Visible:=false; spinedit6.MaxValue:=150; image1.Canvas.Rectangle(-1,-1,1000,1000); n2.Checked:=false; n3.Checked:=false; n4.Checked:=true; n5.Checked:=false; button1.Visible:=false; button2.Visible:=false; button3.Visible:=true; button5.Visible:=false; button6.Visible:=false; ////////////////// image12.Visible:=false; image13.Visible:=false; image14.Visible:=false; label12.Visible:=false; label13.Visible:=false; label14.Visible:=false; ////////////////// ////////////////// trackbar2.Visible:=false; trackbar3.Visible:=false; trackbar4.Visible:=false; image5.Visible:=false; image6.Visible:=false; image7.Visible:=false; ////////////////// ////////////////// button4.Visible:=false; trackbar1.Visible:=false; //////////////////// label4.Visible:=false; label7.Visible:=false; label8.Visible:=false; label9.Visible:=false; /////////////////// spinedit1.Enabled:=false; spinedit2.Enabled:=false; spinedit5.Enabled:=false; spinedit6.Enabled:=true; end; procedure TForm1.N9Click(Sender: TObject); begin Savedialog1.Filter := 'Bitmap files (*.bmp)|*.bmp'; if image1.Visible=true then if SaveDialog1.Execute=true then image1.Picture.SaveToFile(savedialog1.FileName+'.bmp'); if image4.Visible=true then if SaveDialog1.Execute=true then image4.Picture.SaveToFile(savedialog1.FileName+'.bmp'); end; procedure TForm1.N10Click(Sender: TObject); begin form1.Close; end; procedure TForm1.Image4Click(Sender: TObject); var a,b,i,c:integer;P,Vx0,Vy0,Vc,Vs,x,y,Vxx,Vyy,vy,vx,zzz,x1,y1,x2,y2:real; begin if (trackbar5.Position=-18) or (trackbar5.Position=0) or (trackbar5.Position=18) then begin trackbar1.Enabled:=false; Image4.Canvas.Brush.Color:=Clwhite; Image4.Canvas.Rectangle(-1,-1,1060,1060); Image4.Canvas.Pen.Width:=1; Image4.Canvas.Pen.Color:=clBlack; Image4.Canvas.MoveTo(400,0); Image4.Canvas.LineTo(400,600); Image4.Canvas.MoveTo(0,300); Image4.Canvas.LineTo(800,300); a:=abs(Round(form1.spinedit1.value));b:=abs(Round(form1.spinedit2.value)); //Vx0:=form1.spinedit3.value; //Vy0:=form1.spinedit4.value; Vx0:=abs(cos(trackbar5.Position*5/57.3)); Vy0:=-abs(sin(trackbar5.Position*5/57.3)); if (trackbar5.Position=-18) or (trackbar5.Position=18) then Vy0:=-Vy0; Vc:=-Vx0/sqrt(sqr(Vx0)+sqr(Vy0));Vs:=Vy0/sqrt(sqr(Vx0)+sqr(Vy0)); Image4.Canvas.Pen.Width:=1; speed(-400,0,vx,vy); x1:=round(a*Vc);x2:=x1; y1:=round(a*Vs);y2:=y1; if trackbar5.Position=0 then begin image4.Canvas.TextOut(400-trunc(a/2),305,'a'); image4.Canvas.TextOut(405,300-trunc(b/2+7),'b'); end; if (trackbar5.Position=-18) or (trackbar5.Position=18) then begin image4.Canvas.TextOut(400-trunc(b/2),305,'b'); image4.Canvas.TextOut(405,300-trunc(a/2+7),'a'); end; For i:=-a to a do begin ///////////////////verh x:=-i*Vc+b*sqrt(1-sqr(i/a))*Vs; y:=-i*Vs-b*sqrt(1-sqr(i/a))*Vc; if abs(Vx0)>abs(Vy0) then Speed(x,y,Vxx,Vyy); if abs(Vx0)0 then Image4.Canvas.Pen.Color:=Clred; image4.Canvas.MoveTo(400+trunc(x),300-trunc(y)); if abs(Vx0)>abs(Vy0) then begin if 1-x*x/(a*a)<>0 then if x<>0 then begin if p>0 then zzz:=arctan(-b*x/(sqrt(1-x*x/(a*a))*a*a))+pi/2; if p<0 then zzz:=arctan(-b*x/(sqrt(1-x*x/(a*a))*a*a))-pi/2; end;end; if abs(Vx0)0 then if x<>0 then begin if p>0 then zzz:=arctan(-a*x/(sqrt(1-x*x/(b*b))*b*b))+pi/2; if p<0 then zzz:=arctan(-a*x/(sqrt(1-x*x/(b*b))*b*b))-pi/2; end;end; p:=abs(p);c:=c+1; if c/3=trunc(c/3) then begin if abs(Vx0)>abs(Vy0) then image4.Canvas.LineTo( 400+trunc(x+5*p*cos(zzz)) ,300+trunc(-y-5*p*sin(zzz)) ); if abs(Vx0)0 then image4.Canvas.LineTo( 400+trunc(x+5*p*cos(zzz)) ,300+trunc(-y+5*p*sin(zzz)) ); end;end; application.ProcessMessages; x1:=x; y1:=y; /////////////////// niz x:=-i*Vc-b*sqrt(1-sqr(-i/a))*Vs; y:=-i*Vs+b*sqrt(1-sqr(-i/a))*Vc; if abs(Vx0)>abs(Vy0) then Speed(x,y,Vxx,Vyy); if abs(Vx0)0 then Image4.Canvas.Pen.Color:=Clred; image4.Canvas.MoveTo(400+trunc(x),300-trunc(y)); if abs(Vx0)>abs(Vy0) then begin if 1-x*x/(a*a)<>0 then if x<>0 then begin if p>0 then zzz:=arctan(-b*x/(sqrt(1-x*x/(a*a))*a*a))+pi/2; if p<0 then zzz:=arctan(-b*x/(sqrt(1-x*x/(a*a))*a*a))-pi/2; end;end; if abs(Vx0)0 then if x<>0 then begin if p>0 then zzz:=arctan(-a*x/(sqrt(1-x*x/(b*b))*b*b))+pi/2; if p<0 then zzz:=arctan(-a*x/(sqrt(1-x*x/(b*b))*b*b))-pi/2; end;end; p:=abs(p); { c:=c+1; } { if c/3=trunc(c/3) then image4.Canvas.LineTo( 400+trunc(x+5*p*cos(zzz)) ,300-trunc(y-5*p*sin(zzz)) );} if c/3=trunc(c/3) then begin if abs(Vx0)>abs(Vy0) then image4.Canvas.LineTo( 400+trunc(x+5*p*cos(zzz)) ,300-trunc(y-5*p*sin(zzz)) ); if abs(Vx0)0 then image4.Canvas.LineTo( 400+trunc(x+5*p*cos(zzz)) ,300-trunc(y-5*p*sin(zzz)) ); end;end; x2:=x;y2:=y; end; trackbar1.Enabled:=true; Image4.Canvas.Brush.Color:=ClWhite; Image4.Canvas.pen.Color:=Clblack; Image4.Canvas.Pen.Width:=1; Image4.Canvas.Rectangle(0,570,430,600); image4.Canvas.TextOut(10,573,'Параметры : '); image4.Canvas.TextOut(130,573,'a = '+inttostr(a)); image4.Canvas.TextOut(200,573,'b = '+inttostr(b)); image4.Canvas.TextOut(270,573,'Po'); image4.Canvas.TextOut(292,573,'o = '+inttostr(trackbar1.Position)); image4.Canvas.TextOut(350,573,'Vx = '+inttostr(trackbar5.Position*5)); end else begin showmessage('Вывод распределения давлений работает только для случая A = -90 0 90 градусов'); end; End; procedure TForm1.Button4Click(Sender: TObject); begin image1.Visible:=not image1.Visible; image4.Visible:=not image4.Visible; image3.Visible:=image4.Visible; label11.Visible:=image4.Visible; trackbar1.Visible:=image4.Visible; end; procedure TForm1.Image1Click(Sender: TObject); var Vxx,Vyy,O,r,Vr,Vo,Vx,Vy:real;x,y,a7:integer; begin if (n2.Checked=true) or (n3.Checked=true) then if (trackbar5.Position=-18) or (trackbar5.Position=0) or (trackbar5.Position=18) then begin x:=mouse_x;y:=mouse_y; if image1.Canvas.Pixels[x,y]=clred then begin x:=x-400;y:=300-y; speed(x,y,Vxx,Vyy); Vxx:=abs(Vxx); if (trackbar5.Position=18) or (trackbar5.Position=-18) then Vyy:=-Vyy; Image1.Canvas.pen.Color:=Clgreen; Image1.Canvas.pen.Width:=2; image1.Canvas.MoveTo(x+400,-(y-300)); image1.Canvas.LineTo(x+400+trunc(10*Vxx),-(y-300)); image1.Canvas.MoveTo(x+400,-(y-300)); image1.Canvas.LineTo(x+400,-(y-300)-trunc(10*Vyy)); image1.Canvas.MoveTo(x+400,-(y-300)); image1.Canvas.LineTo(x+400+trunc(10*Vxx),-(y-300)-trunc(10*Vyy)); ////////////strelki image1.Canvas.MoveTo(x+400+trunc(10*Vxx),-(y-300)-trunc(10*Vyy)); image1.Canvas.LineTo(x+400+trunc(10*Vxx)-trunc(12*cos(pi/10+arctan(Vyy/Vxx))),-(y-300)-trunc(10*Vyy)+trunc(12*sin(pi/10+arctan(Vyy/Vxx)))); image1.Canvas.MoveTo(x+400+trunc(10*Vxx),-(y-300)-trunc(10*Vyy)); image1.Canvas.LineTo(x+400+trunc(10*Vxx)-trunc(12*cos(-pi/10+arctan(Vyy/Vxx))),-(y-300)-trunc(10*Vyy)+trunc(12*sin(-pi/10+arctan(Vyy/Vxx)))); /////////////////////////// label7.Caption:='Vx = '+FloatToStrF(Vxx,ffgeneral, 4, 2); label8.Caption:='Vy = '+FloatToStrF(Vyy,ffgeneral, 4, 2); end; end else begin showmessage('Вывод векторов скорости работает только для случая A = -90 0 90 градусов'); end; //////////////////////////////////////////////////////////////////////// x:=mouse_x;y:=mouse_y; Image1.Canvas.pen.Color:=Clgreen; Image1.Canvas.pen.Width:=2; a7:=spinedit6.Value; if n5.Checked=true then if image1.Canvas.Pixels[x,y]=clblack then begin O:=arctan2((x-400),(y-300))+pi/2; r:=sqrt(sqr(x-400)+sqr(y-300)); Vr:=5*(1-3*a7/(2*r)+0.5*(a7/r)*(a7/r)*(a7/r))*cos(O); Vo:=-5*(1-3*a7/(4*r)-0.25*(a7/r)*(a7/r)*(a7/r))*sin(O)/r; Vx:=abs(Vr*cos(Vo)); Vy:=Vr*sin(Vo); image1.Canvas.MoveTo(x,y); image1.Canvas.LineTo(x+trunc(20*Vx),y); image1.Canvas.MoveTo(x,y); image1.Canvas.LineTo(x,y-trunc(4000*Vy)); image1.Canvas.MoveTo(x,y); image1.Canvas.LineTo(x+trunc(20*Vx),y-trunc(4000*Vy)); ////////////strelki image1.Canvas.MoveTo(x+trunc(20*Vx),y-trunc(4000*Vy)); image1.Canvas.LineTo(x+trunc(20*Vx)-trunc(12*cos(pi/10+arctan(200*Vy/Vx))),y-trunc(4000*Vy)+trunc(12*sin(pi/10+arctan(200*Vy/Vx)))); image1.Canvas.MoveTo(x+trunc(20*Vx),y-trunc(4000*Vy)); image1.Canvas.LineTo(x+trunc(20*Vx)-trunc(12*cos(-pi/10+arctan(200*Vy/Vx))),y-trunc(4000*Vy)+trunc(12*sin(-pi/10+arctan(200*Vy/Vx)))); /////////////////////////// //form1.Caption:=floattostr(Vx)+' '+floattostr(Vy)+' '+floattostr(O*57.3); end; end; procedure TForm1.TrackBar1Change(Sender: TObject); begin label11.Caption:='= '+inttostr(trackbar1.position); end; procedure TForm1.Button5Click(Sender: TObject); Var Vr,Vo,V,O,O1,r,r1,x,y,x1,y1,p,poo,f:real; a,i,n,O2:integer; Begin a:=spinedit6.Value; V:=1;{trackbar1.Position; } Image1.Canvas.Brush.Color:=ClWhite; Image1.Canvas.Rectangle(-10,-10,810,610); Image1.Canvas.Pen.Width:=2; Image1.Canvas.Pen.Color:=clblue; image1.Canvas.Ellipse(400-a,300-a,400+a,300+a); image1.Canvas.Pixels[400,300]:=clblack; Image1.Canvas.Pen.Color:=clblack; For i:=0 to 32 do begin r:=500; O:=Pi*(135+i*90/32)/180; x:=r*cos(O); y:=r*sin(O); while (x<500) and (x>-500) and (y<500) and (y>-500) do begin Vr:=V*(1-3*a/(2*r)+0.5*(a/r)*(a/r)*(a/r))*cos(O); Vo:=-V*(1-3*a/(4*r)-0.25*(a/r)*(a/r)*(a/r))*sin(O)/r; r1:=r+Vr; O1:=O+Vo; x1:=r1*cos(O1); y1:=r1*sin(O1); if (x1<500) and (x1>-500) and (y1<400) and (y1>-400) then begin image1.Canvas.MoveTo(trunc(400+x),trunc(300-y)); image1.Canvas.LineTo(trunc(400+x1),trunc(300-y1)); end; r:=r1;O:=O1;x:=x1;y:=y1; if (sqr(Vr)+sqr(Vo))<1E-7 then x:=501; end; end; V:=trackbar2.Position; case trackbar3.Position of 1:n:=1; 2:n:=6; 3:n:=9; 4:n:=10; end; poo:=trackbar4.Position; Image1.Canvas.Pen.Width:=1; for O2:=0 to 180 do if O2/2=trunc(O2/2) then begin f:=Pi*O2/90; p:=poo-1.5*n*V*cos(f)/a; p:=p*7; if p>0 then Image1.Canvas.Pen.Color:=clred; if p<0 then Image1.Canvas.Pen.Color:=clgreen; image1.Canvas.MoveTo(trunc(400+a*cos(f)),trunc(300-a*sin(f)) ); image1.Canvas.LineTo(trunc(400+(p+a)*cos(f)),trunc(300-(p+a)*sin(f))); end; Image1.Canvas.Brush.Color:=ClWhite; Image1.Canvas.pen.Color:=Clblack; Image1.Canvas.Pen.Width:=1; Image1.Canvas.Rectangle(0,570,730,600); image1.Canvas.TextOut(5,573,'Линии тока и распределение давления при обтекании шара вязкой жидкостью'); end; procedure TForm1.N5Click(Sender: TObject); begin groupbox1.visible:=false; image1.Canvas.Rectangle(-1,-1,1000,1000); ///////////////////////////////////// n2.Checked:=false; n3.Checked:=false; n4.Checked:=false; n5.Checked:=true; /////////////////// spinedit6.Enabled:=true; //////////////////// image4.Visible:=false; image1.Visible:=true; ////////////////// image12.Visible:=true; image13.Visible:=true; image14.Visible:=true; label12.Visible:=true; label13.Visible:=true; label14.Visible:=true; ////////////////// spinedit1.Enabled:=false; spinedit2.Enabled:=false; spinedit5.Enabled:=false; label4.Visible:=true; ///////////////////// button1.Visible:=false; button2.Visible:=false; button3.Visible:=false; button4.Visible:=false; button5.Visible:=true; button6.Visible:=false; button7.Visible:=false; /////////////////////// image6.Visible:=true; image7.Visible:=true; image5.Visible:=true; trackbar2.Visible:=true; trackbar3.Visible:=true; trackbar4.Visible:=true; ////////////////////// label7.Visible:=false; label8.Visible:=false; label9.Visible:=false; ////////////////////// trackbar1.Visible:=false; image3.Visible:=false; label11.Visible:=false; end; procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); begin Mouse_x:=x; Mouse_y:=y; end; procedure TForm1.Timer1Timer(Sender: TObject); Const t=0.05; Var Vx0,Vy0,Vx,Vy,Vs,x,y,x1,y1,xx,yy,xx1,yy1,z1,z2,a0,b0,K,Cs,Sn:real; b,c,i,p:integer; Begin if i1>trunc(a1*3/5) then timer1.Enabled:=false else i1:=i1+1; b:=a1-i1; a:=trunc(a1*a1/b); Image1.Canvas.Brush.Color:=ClWhite; Image1.Canvas.Rectangle(-10,-10,810,610); Image1.Canvas.Pen.Width:=1; Image1.Canvas.Pen.Color:=clBlack; Image1.Canvas.MoveTo(400,0); Image1.Canvas.LineTo(400,600); Image1.Canvas.MoveTo(0,300); Image1.Canvas.LineTo(800,300); Vx0:=0; Vy0:=5; Vs:=Vy0/sqrt(sqr(Vy0)); Image1.Canvas.Pen.Width:=2; Image1.Canvas.Pen.Color:=Clblue; Image1.Canvas.MoveTo(round(400),round(300-a*Vs)); image1.Canvas.Ellipse(400-b,300-a,400+b,300+a); Image1.Canvas.Pen.Color:=ClRed; p:=11; c:=abs(sqr(a)-sqr(b)); a0:=(1+sqr(a+b)/c)/2; b0:=(1-sqr(a+b)/c)/2; For i:=1-p to p do if i<>0 then begin if Vx0=0 then begin x:=32*i; y:=-500*Vs; end; while ((x>-800) and (x<800) and (y>-800) and (y<0)) do begin yy:=2*x*y; xx:=sqr(x)-sqr(y)-c; K:=sqrt(sqr(xx)+sqr(yy)); if y<0 then Sn:=-sqrt((1-xx/k)/2); if x<0 then Cs:=-sqrt((1+xx/k)/2) else Cs:=sqrt((1+xx/k)/2); K:=sqrt(K); z1:=(x*Cs+y*Sn)/K; z2:=(y*Cs-x*Sn)/K; Vx:=Vy0*a0*z2; Vy:=Vy0*b0+Vy0*a0*z1; x1:=x+Vx*t; y1:=y+Vy*t; xx:=+y*Vs; yy:=-x*Vs; xx1:=y1*Vs; yy1:=-x1*Vs; if ((xx>-400) and (xx<0) and (yy>-300) and (yy<300)) then begin Image1.Canvas.MoveTo(round(400+xx),round(300-yy)); Image1.Canvas.LineTo(round(400+xx1),round(300-yy1)); Image1.Canvas.MoveTo(round(400-xx),round(300-yy)); Image1.Canvas.LineTo(round(400-xx1),round(300-yy1)); end; x:=x1; y:=y1; if sqr(x/a)+sqr(y/b)<=1 then x:=801; if sqr(Vx)+sqr(Vy)<1E-5 then x:=801; end; end; Image1.Canvas.Brush.Color:=ClWhite; Image1.Canvas.pen.Color:=Clblack; Image1.Canvas.Pen.Width:=1; Image1.Canvas.Rectangle(0,570,270,600); image1.Canvas.TextOut(10,573,'Параметры : '); image1.Canvas.TextOut(130,573,'a = '+inttostr(a)); image1.Canvas.TextOut(200,573,'b = '+inttostr(b)); //image1.Canvas.TextOut(270,573,'n = '+inttostr(32)); //image1.Canvas.TextOut(340,573,'Vx = '+floattostr(Vx0)); //image1.Canvas.TextOut(410,573,'Vy = '+floattostr(Vy0)); application.ProcessMessages; button2.Enabled:=true; spinedit6.Enabled:=true; timer1.Enabled:=false; end; procedure TForm1.Button6Click(Sender: TObject); begin if button2.Visible=true then timer1.Enabled:=not timer1.Enabled; if button3.Visible=true then begin timer2.Enabled:=not timer2.Enabled; button7.Visible:=not button7.Visible;end; end; procedure TForm1.Timer2Timer(Sender: TObject); Const t=0.5; Var Vx0,Vy0,Vx,Vy,Vc,Vs,x,y,x1,y1,xx,yy,xx1,yy1,z1,z2,a0,b0,K,Cs,Sn:real; a,b,c,i,j:integer; Begin Vx0:=1;Vy0:=0; if i2>trunc(a2/2) then timer2.Enabled:=false else begin x0:=x0+1;if (x0/trunc((1.25*800/a2)))=trunc(x0/trunc((1.25*800/a2))) then i2:=i2+1;end; Image1.Canvas.Brush.Color:=ClWhite; Image1.Canvas.Rectangle(-10,-10,810,610); Image1.Canvas.Pen.Width:=1; Image1.Canvas.Pen.Color:=clBlack; Image1.Canvas.MoveTo(400,0); Image1.Canvas.LineTo(400,600); Image1.Canvas.MoveTo(0,300); Image1.Canvas.LineTo(800,300); b:=a2-i2; a:=trunc(a2*a2/b); Vc:=-Vx0/sqrt(sqr(Vx0));Vs:=0; Image1.Canvas.Pen.Width:=1; Image1.Canvas.Pen.Color:=Clblue; Image1.Canvas.MoveTo(round(400+a*Vc),round(300-a*Vs)); image1.Canvas.Ellipse(x0+400-a,300-b,x0+400+a,300+b); Image1.Canvas.Pen.Color:=ClRed; c:=abs(sqr(a)-sqr(b)); a0:=(1+sqr(a+b)/c)/2; b0:=(1-sqr(a+b)/c)/2; for j:=1 to 2 do For i:= 1 to 7 do begin if Vy0=0 then begin x:=-(a/8)*i; if j=1 then y:=b*sqrt(1-sqr(abs((a/8)*i)/a)); if j=2 then y:=-b*sqrt(1-sqr(abs((a/8)*i)/a)); end; while ((x>-800) and (x<800) and (y>-800) and (y<800)) do begin yy:=2*x*y; xx:=sqr(x)-sqr(y)-c; K:=sqrt(sqr(xx)+sqr(yy)); if y<0 then Sn:=-sqrt((1-xx/k)/2) else Sn:=sqrt((1-xx/k)/2); if x<0 then Cs:=-sqrt((1+xx/k)/2) else Cs:=sqrt((1+xx/k)/2); K:=sqrt(K); z1:=(x*Cs+y*Sn)/K; z2:=(y*Cs-x*Sn)/K; Vx:=Vx0*a0+Vx0*b0*z1-Vx0; Vy:=-Vx0*b0*z2-Vy0; x1:=x+Vx*t; y1:=y+Vy*t; xx:=-x*Vc+y*Vs; yy:=-x*Vs-y*Vc; xx1:=-x1*Vc+y1*Vs; yy1:=-x1*Vs-y1*Vc; if ((xx>-500) and (xx<500) and (yy>-400) and (yy<400)) then begin Image1.Canvas.MoveTo(round(x0+400+xx),round(300-yy)); Image1.Canvas.LineTo(round(x0+400+xx1),round(300-yy1)); end; x:=x1; y:=y1; if sqr(x/a)+sqr(y/b)<=1 then x:=801; if sqr(Vx)+sqr(Vy)<1E-5 then x:=801; end; end; application.ProcessMessages; end; procedure TForm1.Button7Click(Sender: TObject); var a,b,i,c:integer;P,Vx0,Vy0,Vc,Vs,x,y,Vxx,Vyy,vy,vx,zzz:real; begin Image1.Canvas.Brush.Color:=Clwhite; Image1.Canvas.Rectangle(-1,-1,1060,1060); Image1.Canvas.Pen.Width:=1; Image1.Canvas.Pen.Color:=clBlack; Image1.Canvas.MoveTo(400,0); Image1.Canvas.LineTo(400,600); Image1.Canvas.MoveTo(0,300); Image1.Canvas.LineTo(800,300); b:=spinedit6.Value-trunc(i2); a:=Round(spinedit6.Value*spinedit6.Value/b); Vx0:=5;Vy0:=0; Vc:=-Vx0/sqrt(sqr(Vx0)+sqr(Vy0));Vs:=Vy0/sqrt(sqr(Vx0)+sqr(Vy0)); Image1.Canvas.Pen.Width:=1; speed(-400,0,vx,vy); image1.Canvas.Ellipse(x0+400-a,300-b,x0+400+a,300+b); For i:=-a to a do begin ///////////////////verh x:=-i*Vc+b*sqrt(1-sqr(i/a))*Vs; y:=-i*Vs-b*sqrt(1-sqr(i/a))*Vc; if abs(Vx0)0 then Image4.Canvas.Pen.Color:=Clred; image1.Canvas.MoveTo(x0+400+trunc(x),300-trunc(y)); if abs(Vx0)0 then if x<>0 then begin if p>0 then zzz:=arctan(-a*x/(sqrt(1-x*x/(b*b))*b*b))+pi/2; if p<0 then zzz:=arctan(-a*x/(sqrt(1-x*x/(b*b))*b*b))-pi/2; end;end; p:=abs(p);c:=c+1; if c/2=trunc(c/2) then image1.Canvas.LineTo(x0+400+trunc(x+5*p*cos(zzz)) ,300+trunc(-y-5*p*sin(zzz)) ); application.ProcessMessages; /////////////////// niz x:=-i*Vc-b*sqrt(1-sqr(-i/a))*Vs; y:=-i*Vs+b*sqrt(1-sqr(-i/a))*Vc; if abs(Vx0)>abs(Vy0) then Speed(x,y,Vxx,Vyy); if abs(Vx0)0 then Image1.Canvas.Pen.Color:=Clred; image1.Canvas.MoveTo(x0+400+trunc(x),300-trunc(y)); if 1-x*x/(a*a)<>0 then if x<>0 then begin if p>0 then zzz:=arctan(-b*x/(sqrt(1-x*x/(a*a))*a*a))+pi/2; if p<0 then zzz:=arctan(-b*x/(sqrt(1-x*x/(a*a))*a*a))-pi/2; end; p:=abs(p); if c/2=trunc(c/2) then image1.Canvas.LineTo(x0+400+trunc(x+5*p*cos(zzz)) ,300-trunc(y-5*p*sin(zzz)) ); end; Image1.Canvas.Brush.Color:=ClWhite; Image1.Canvas.pen.Color:=Clblack; Image1.Canvas.Pen.Width:=1; Image1.Canvas.Rectangle(0,570,260,600); image1.Canvas.TextOut(10,573,'Параметры : '); image1.Canvas.TextOut(130,573,'a = '+inttostr(a)); image1.Canvas.TextOut(200,573,'b = '+inttostr(b)); end; procedure TForm1.N6Click(Sender: TObject); begin {form2.Left:=form1.left+trunc(form1.Width/2-form2.Width/2); form2.top:=form1.top+form1.Height; form2.visible:=true; } end; procedure TForm1.Timer3Timer(Sender: TObject); begin if form1.n2.Checked=false then if form1.n3.Checked=false then if form1.n4.Checked=false then if form1.n5.Checked=false then begin label10.Visible:=true; image2.Visible:=false; image8.Visible:=false; image9.Visible:=false; image10.Visible:=false; image11.Visible:=false; end; if form1.n2.Checked=true then begin label10.Visible:=false; image2.Visible:=true; image8.Visible:=false; image9.Visible:=false; image10.Visible:=false; image11.Visible:=false; end; if form1.n3.Checked=true then begin label10.Visible:=false; image2.Visible:=false; image8.Visible:=false; image9.Visible:=false; image10.Visible:=true; image11.Visible:=false; end; if form1.n4.Checked=true then begin label10.Visible:=false; image2.Visible:=false; image8.Visible:=false; image9.Visible:=false; image10.Visible:=false; image11.Visible:=true; end; if form1.n5.Checked=true then begin label10.Visible:=false; image2.Visible:=false; image8.Visible:=true; image9.Visible:=true; image10.Visible:=false; image11.Visible:=false; end; end; procedure TForm1.Button8Click(Sender: TObject); begin memo1.Visible:=false; button8.Visible:=false; end; procedure TForm1.TrackBar3Change(Sender: TObject); begin //label12.Caption:='= '+FloatToStrF(1.8E-5+(trackbar3.Position-2)*(1E-3-1.8E-5)/9,ffgeneral, 4, 2)+ ' Н*с/м^2'; case trackbar3.Position of 1:label12.Caption:='= 1.8E-5 Н*с/м^2'; 2:label12.Caption:='= 1.0E-3 Н*с/м^2'; 3:label12.Caption:='= 1.6E-3 Н*с/м^2'; 4:label12.Caption:='= 1.8E-3 Н*с/м^2'; end; case trackbar3.Position of 1:label4.Caption:='Вещество - воздух'; 2:label4.Caption:='Вещество - вода'; 3:label4.Caption:='Вещество - ртуть'; 4:label4.Caption:='Вещество - спирт'; end; //if trackbar3.Position=2 then label12.Caption:=label12.Caption+' - Воздух'; //if trackbar3.Position=11 then label12.Caption:=label12.Caption+' - Вода'; end; procedure TForm1.TrackBar4Change(Sender: TObject); begin label13.Caption:='= '+FloatToStrF(0.01+(trackbar4.Position-1)*(1-0.1)/90,ffgeneral, 4, 2)+' МПа'; end; procedure TForm1.TrackBar2Change(Sender: TObject); begin label14.Caption:='= '+FloatToStrF((1+(trackbar2.Position-1)*(100-1)/99)/100,ffgeneral, 4, 2)+' м/с'; end; procedure TForm1.TrackBar5Change(Sender: TObject); begin label3.Caption:='А = '+inttostr(trackbar5.position*5); end; end.