|
|
Регистрация Восстановить пароль |
Повторная активизация e-mail |
Регистрация | Задать вопрос |
Заплачу за решение |
Новые сообщения |
Сообщения за день |
Расширенный поиск |
Правила |
Всё прочитано |
|
Опции темы | Поиск в этой теме |
17.12.2017, 16:56 | #1 |
Регистрация: 28.11.2017
Сообщений: 4
|
Автоматическое масштабирование графика delphi 7
Помогите , нужно сделать автоматическое масштабирование графика.Задача на моделирование полета тела.Если указываю скорость =10 то график полета тела почти не видно, как исправить?
type TForm1 = class(TForm) Edit1: TEdit; Edit2: TEdit; Edit3: TEdit; Edit4: TEdit; Button1: TButton; Label1: TLabel; Label2: TLabel; Label3: TLabel; Edit5: TEdit; Label4: TLabel; Label5: TLabel; Label6: TLabel; Label7: TLabel; Button2: TButton; PageControl1: TPageControl; TabSheet1: TTabSheet; TabSheet2: TTabSheet; Edit6: TEdit; Edit7: TEdit; Edit8: TEdit; Edit9: TEdit; Edit10: TEdit; Edit11: TEdit; Edit12: TEdit; Edit13: TEdit; Button3: TButton; Label8: TLabel; Label9: TLabel; Label10: TLabel; Label11: TLabel; Label12: TLabel; Label13: TLabel; Label14: TLabel; Button4: TButton; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure Button3Click(Sender: TObject); procedure Button4Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); var x0,y0,u0,a0,L,t,H,x,y:real; i,j:integer; Const g = 9.8; begin x0:=strtofloat(edit1.text); y0:=strtofloat(edit2.text); u0:=strtofloat(edit3.text); a0:=strtofloat(edit4.text)*pi/180; if u0<>0 then t:=(u0/g)*(sin(a0)+sqrt(sqr(sin(a0))+(2*g* y0)/(u0*u0)))//Полное время полета тела else t:=sqrt(2*(H+y0)/g); label1.Caption:='tp='+floattostr(t) ; if (strtofloat(edit4.text)<>0) and (strtofloat(edit4.text)<>180) and (u0<>0) then L:=(u0*u0*sin(2*(a0))/(2*g))*(1+sqrt(1+(2*g*y0/sqr(u0*sin(a0)))))//Дальность полета тела от начальной точки else L:=u0*sqrt(2*y0/g);//Дальность полета брошенного параллельно земле label2.Caption:='L='+floattostr(L); H:=sqr(u0*sin(a0))/(2*g);//Максимальная высота от тела если прибавить y0 получим максимальную высоту от земли label3.Caption:='H='+floattostr(H); with canvas do begin pen.Style:=pssolid; pen.Color:=clblack;//Начало moveto(50,400); lineto(50,200); lineto(45,210); moveto(50,200); lineto(55,210); moveto(50,400); lineto(750,400); lineto(740,395); moveto(750,400); lineto(740,405); i:=50; while i<750 do begin moveto(i,405); lineto(i,395); if ((i-50) mod 30) = 0 then textout(i-4, 410, inttostr(i-50)); i:=i+10; end; i:=400; while i>200 do begin moveto(45,i); lineto(55,i); if ((i-400) mod 30) = 0 then textout(25, i-7, inttostr((i-400)*(-1))); i:=i-10; end;//Конец(строится координатная плоскость) pen.Color:=clred; ellipse(45+round(x0),395-round(y0),55+round(x0),405-round(y0));//ставится красная начальная точка полета тела moveto(50+round(x0),400-round(y0)); pen.Color:=clblue; pen.Style:=psdot; x:=x0+(u0*cos(a0))*t; //X(t) отсюда выразим t=(x-x0)/(u0*cos(a0)) if (strtofloat(edit4.text)<>90) and (strtofloat(edit4.text)<>270) and (u0<>0) then for i:=round(x0) to round(x) do begin y:=y0+(u0*sin(a0))*((i-x0)/(u0*cos(a0)))-0.5*g*sqr((i-x0)/(u0*cos(a0)));//Y(t) сделаем замену t=(i-x0)/(u0*cos(a0)) lineto(50+i,400-round(y)); sleep(5); end else begin for i:=400-round(y0) downto 400-round(H+y0) do begin lineto(50+round(x0), i); sleep(5); end; for i:=400-round(H+y0) to 400 do begin lineto(50+round(x0), i); sleep(5); end; end; Button2.Enabled:=True; Button2.Caption:='Доступно' end; Edit6.Text:=edit1.text; Edit7.Text:=edit2.text; Edit8.Text:=edit3.text; Edit9.Text:=edit4.text; end; procedure TForm1.Button2Click(Sender: TObject); var t,x,y,u,a,x0,y0,u0,a0:real; Const g = 9.8; begin x0:=strtofloat(edit1.text); y0:=strtofloat(edit2.text); u0:=strtofloat(edit3.text); a0:=strtofloat(edit4.text)*pi/180; t:=strtofloat(edit5.text); x:=x0+u0*cos(a0)*t; label4.Caption:='X(t)='+floattostr( x); y:=y0+(u0*sin(a0))*t-0.5*g*t*t; label5.Caption:='Y(t)='+floattostr( y); u:=sqrt(sqr(u0*cos(a0))+sqr(u0*sin( a0)-g*t)); label6.Caption:='U(t)='+floattostr( u); a:=arctan(((u0*sin(a0)-g*t)/(u0*cos(a0))))*180/pi; label7.Caption:='Al(t)='+floattostr (a); with canvas do // begin //pen.Color:=clred; //ellipse(45+round(x),395-round(y),55+round(x),405-round(y));//ставится красная начальная точка полета тела //moveto(50+round(x),400-round(y)); //end; end; procedure TForm1.Button3Click(Sender: TObject); var max,w,p,mx,my,x0,y0,u0,a0,L,t,H,y,m ,S,Cx,F,ro,Ux,Uy,xi,yi,Uxi,Uyi,a,ts :real; Q,i:integer; Const g=9.8; Const ro0=1.2; Const dt=0.001; begin x0:=strtofloat(edit6.text); y0:=strtofloat(edit7.text); u0:=strtofloat(edit8.text); a0:=strtofloat(edit9.text)*pi/180; m:=strtofloat(edit10.text); S:=strtofloat(edit11.text); Cx:=strtofloat(edit12.text); Ux:=u0*cos(a0); Uy:=u0*sin(a0); xi:=x0; yi:=y0; L:=x0; H:=y0; t:=0; ts:=0; y0:=Q; with canvas do begin pen.Style:=pssolid; pen.Color:=clblack;//Начало moveto(50,400); lineto(50,i); lineto(45,i); moveto(50,200); lineto(55,i); moveto(50,400); lineto(750,i); lineto(740,i); moveto(750,400); lineto(740,i); i:=50; while i<750 do begin moveto(i,405); lineto(i,395); if ((i-50) mod 30) = 0 then textout(i-4, 410, inttostr(i-50)); i:=i+10; end; i:=400; while i>200 do begin moveto(45,i); lineto(55,i); if ((i-400) mod 30) = 0 then textout(25, i-7, inttostr((i-400)*(-1))); i:=i-10; end;//Конец(строится координатная плоскость) pen.Color:=clred; ellipse(45+round(x0),395-round(y0),55+round(x0),405-round(y0));//ставится красная начальная точка полета тела moveto(50+round(x0),400-round(y0)); pen.Color:=clgreen; pen.Style:=psdot; while (yi>=0) do begin ts:=Roundto(t,-3)+dt; Uxi:=Ux-(Cx*S*ro0*(1-yi/12000)*(power(Ux,2)+ power(Uy,2))*cos(ArcTan(Uy/Ux))*dt)/(2*m); Uyi:=Uy-(g+(Cx*S*ro0*(1-yi/12000)*(power(Ux,2)+ power(Uy,2))*sin(ArcTan(Uy/Ux)))/(2*m))*dt; xi:=xi+Uxi*dt; yi:=yi+Uyi*dt; lineto(50+round(xi),400-round(yi)); if (xi>L) then L:=xi; if (yi>H) then H:=yi; Ux:=Uxi; Uy:=Uyi; t:=ts; end; end; label8.Caption:='tp='+floattostr(t) ; label9.Caption:='L='+floattostr(L); label10.Caption:='H='+floattostr(H) ; Button4.Enabled:=True; Button4.Caption:='Доступно'; Edit1.Text:=edit6.text; Edit2.Text:=edit7.text; Edit3.Text:=edit8.text; Edit4.Text:=edit9.text; end; procedure TForm1.Button4Click(Sender: TObject); var x0,y0,u0,a0,L,t,H,y,m,S,Cx,F,ro,Ux, Uy,xi,yi,Uxi,Uyi,a,ts,tm,u:real; i:integer; Const g=9.8; Const ro0=1.2; Const dt=0.001; begin x0:=strtofloat(edit6.text); y0:=strtofloat(edit7.text); u0:=strtofloat(edit8.text); a0:=strtofloat(edit9.text)*pi/180; m:=strtofloat(edit10.text); S:=strtofloat(edit11.text); Cx:=strtofloat(edit12.text); tm:=strtofloat(edit13.text); Ux:=u0*cos(a0); Uy:=u0*sin(a0); xi:=x0; yi:=y0; L:=x0; H:=y0; t:=0; ts:=0; while (t<=tm) do begin ts:=Roundto(t,-3)+dt; Uxi:=Ux-(Cx*S*ro0*(1-yi/12000)*(power(Ux,2)+ power(Uy,2))*cos(ArcTan(Uy/Ux))*dt)/(2*m); Uyi:=Uy-(g+(Cx*S*ro0*(1-yi/12000)*(power(Ux,2)+ power(Uy,2))*sin(ArcTan(Uy/Ux)))/(2*m))*dt; xi:=xi+Uxi*dt; yi:=yi+Uyi*dt; if t=tm then begin label11.Caption:='X(t)='+floattostr (xi); label12.Caption:='Y(t)='+floattostr (yi); a:=ArcTan(Uyi/Uxi); u:=sqrt(sqr(Uxi)+sqr(Uyi)); label13.Caption:='U(t)='+floattostr (u); label14.Caption:='Al(t)='+floattost r(a/pi*180); Ux:=Uxi; Uy:=Uyi; t:=ts; end; end; end. |
Похожие темы | ||||
Тема | Автор | Раздел | Ответов | Последнее сообщение |
Автоматическое масштабирование сайта | skaut | WordPress и другие CMS | 1 | 29.04.2017 00:32 |
Масштабирование графика | OlyaV | Помощь студентам | 1 | 02.12.2013 10:00 |
Автоматическое изменение графика при переносе данных, формулы и графика на другой лист | REztor | Microsoft Office Excel | 0 | 01.06.2013 18:01 |
Автоматическое масштабирование окна приложения | panda30 | WPF, UWP, WinRT, XAML | 8 | 08.08.2012 17:21 |
масштабирование графика | densan | Помощь студентам | 2 | 22.01.2009 14:11 |