Advertisement
Guest User

Untitled

a guest
Jul 17th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 5.51 KB | None | 0 0
  1. procedure TForm2.Button2Click(Sender: TObject);
  2. begin
  3.   if OpenDialog1.Execute then
  4.   begin
  5.     Assignfile(t, opendialog1.filename);
  6.     reset(t);
  7.       while not eof(t) do
  8.         begin
  9.             readln(t,ss);
  10.             memo2.Lines.add(ss);
  11.         end;//whileeof
  12. end;//if
  13.  
  14. end;//proc
  15. procedure TForm2.N4Click(Sender: TObject);
  16. begin
  17.   panel2.Visible:=true;
  18. end;
  19.  
  20. procedure TForm2.Button3Click(Sender: TObject);
  21. begin
  22.   panel1.visible:=false;
  23. end;
  24.  
  25. procedure TForm2.Button4Click(Sender: TObject);
  26. begin
  27.   panel2.Visible:=false;
  28. end;
  29.  
  30. procedure TForm2.N6Click(Sender: TObject);
  31. var g,m,s,vx,vy,xk,yk,fx,fy,summas,alfak,sbeta,sumb,fbeta,vbeta,yn,xn,sumdx, sumdy,dxteor,dyteor,fbetad,gk:real;
  32. xks,yks,name1,name2:string;
  33. begin
  34. StringGrid1.Visible:=true;
  35. StringGrid1.Cells[0,0]:='N/n';
  36. StringGrid1.Cells[1,0]:='Beta';
  37. StringGrid1.Cells[2,0]:='Alfa';
  38. StringGrid1.Cells[3,0]:='S';
  39. StringGrid1.Cells[4,0]:='dx';
  40. StringGrid1.Cells[5,0]:='dy';
  41. StringGrid1.Cells[6,0]:='Xвыч';
  42. StringGrid1.Cells[7,0]:='Yвыч';
  43. if OpenDialog1.Execute then
  44.   begin
  45.   assignfile(t, opendialog1.filename);
  46.   reset(t);
  47.   readln(t,ss);
  48.   stringgrid1.cells[0,1]:=ss;
  49.   readln(t,ss);
  50.   stringgrid1.cells[0,3]:=ss;
  51.   readln(t,x[0]);
  52.   str(x[0]:12:3,ss);
  53.   stringgrid1.cells[6,3]:=ss;
  54.   readln(t,y[0]);
  55.   str(y[0]:12:3,ss);
  56.   stringgrid1.cells[7,3]:=ss;
  57.   readln(t,name1);
  58.   readln(t,name2);
  59.   readln(t,ss);
  60.   xks:=ss;
  61.   readln(t,ss);
  62.   yks:=ss;
  63.   readln(t,g,m,s);
  64.   alfa1[0]:=(g+m/60+s/3600)/180*pi;//стандартное преобразование градусов в радианы
  65.   str(g:4:0, ss);
  66.   str(m:5:0, ss1);
  67.   str(s:6:1, ss2);
  68.   stringgrid1.cells[2,2]:=ss+ss1+ss2;
  69.   readln(t, g,m,s);
  70.   alfak:=(g+m/60+s/3600)/180*pi;//стандартное преобразование градусов в радианы
  71.  
  72.   readln(t,i);
  73.   sbeta:=0;
  74.   for j:=0 to i-1 do begin
  75.     ;
  76.       if length(beta)<= j then begin
  77.         setlength(beta, length(beta)+1);
  78.         end;// endif
  79.         readln(t,g,m,s);
  80.         beta[j]:=(g+m/60+s/3600)/180*pi;
  81.         str(g:4:0, ss);
  82.         str(m:5:0, ss1);
  83.         str(s:6:1, ss2);
  84.         sbeta:=sbeta+beta[j];
  85.         stringgrid1.cells[1,3+j*2]:=ss+ss1+ss2;
  86.  
  87.  
  88.       if stringgrid1.RowCount <= 3+j*2+4 then
  89.           stringgrid1.RowCount:= 3+j*3;
  90.   end;//endfor
  91. stringgrid1.cells[0,3+(i-1)*2]:=name1;
  92. stringgrid1.cells[0,3+(i-1)*2+2]:=name2;
  93. stringgrid1.cells[6,3+(i-1)*2]:=xks;
  94. stringgrid1.cells[7,3+(i-1)*2]:=yks;
  95. Form1.rg(alfak);
  96. stringgrid1.cells[2,3+(i-1)*2+1]:=ss+ss1+ss2;
  97. Form1.rg(sbeta);
  98. stringgrid1.cells[1,3+(i-1)*2+3]:=ss+ss1+ss2;
  99. sumb:=alfak-alfa1[0]+pi*i;
  100. Form1.rg(sumb);
  101. stringgrid1.cells[1,3+(i-1)*2+4]:=ss+ss1+ss2;
  102. fbeta:=sbeta - sumb;
  103. Form1.rg(fbeta);
  104. stringgrid1.cells[1,3+(i-1)*2+5]:=ss+ss1+ss2;
  105. fbetad:=5/3600/180*pi*sqr(i);
  106. Form1.rg(fbetad);
  107. stringgrid1.cells[1,3+(i-1)*2+6]:=ss+ss1+ss2;
  108.  
  109. if abs(fbeta) > fbetad then begin
  110.   if messagedlg ('Угловая невязка превышает допустимую. Продолжить вычисления?',
  111.   mtConfirmation, [mbYes, mbNo], 0) = mrNo then exit;
  112. end; // fbeta > fbetad if
  113. vbeta:=-(fbeta/i);
  114. for j:=1 to i do begin
  115.   if length(alfa1)<= j then setlength(alfa1,length(alfa1)+1);
  116.   alfa1[j]:=alfa1[j-1] + beta[j-1] + vbeta;
  117.   if alfa1[j]>Pi then  alfa1[j]:=alfa1[j]-Pi
  118.   else alfa1[j]:=alfa1[j]+Pi;
  119.   if alfa1[j]>2*pi then alfa1[j]:=alfa1[j]-360;
  120.   Form1.rg(alfa1[j]);
  121.   stringgrid1.cells[2,4+(j-1)*2]:=ss+ss1+ss2;
  122. end; // for j
  123. summas:=0;
  124.  
  125. for j:=1 to i-1 do begin
  126.     if length(s1) <=j then setlength(s1,length(s1)+1);
  127.     readln(t,s1[j-1]);
  128.     Str(s1[j-1]:12:3,ss);
  129.     summas:=summas+s1[j-1];
  130.     Stringgrid1.cells[3,4+(j-1)*2]:=ss;
  131. end;  // for j;
  132.  
  133. Str(summas:12:3,ss);
  134. Stringgrid1.Cells[3,3+(i-1)*2+3]:=ss;
  135. dxteor:=xn-x[0];
  136. dyteor:=yn-y[0];
  137. Str(dxteor:12:3,ss1);
  138. Str(dyteor:12:3,ss2);
  139. Stringgrid1.cells[6,3+(i-1)*2+3]:=ss1;
  140. Stringgrid1.cells[7,3+(i-1)*2+3]:=ss2;
  141. sumdx:=0;
  142. sumdy:=0;
  143.  
  144. for j:=1 to i-1 do begin
  145.     if length(dx1) <= j then setLength(dx1, length(dx1)+1);
  146.     if length(dy1) <= j then setLength(dy1, length(dy1)+1);
  147.     dx1[j-1]:=s1[j-1]*cos(alfa1[j]);
  148.     dy1[j-1]:=s1[j-1]*sin(alfa1[j]);
  149.     sumdx:=sumdx+dx1[j-1];
  150.     sumdy:=sumdy+dy1[j-1];
  151.     Str(dx1[j-1]:12:3,ss1);
  152.     Str(dy1[j-1]:12:3,ss2);
  153.     Stringgrid1.cells[4,4+(j-1)*2]:=ss1;
  154.     Stringgrid1.cells[5,4+(j-1)*2]:=ss2;
  155.       if j < i-1 then begin
  156.           Str(j,ss);
  157.           Stringgrid1.cells[0,5+(j-1)*2]:=ss;
  158.       end;
  159. end;
  160. Str(sumdx:12:3,ss1);
  161. str(sumdy:12:3,ss2);
  162. Stringgrid1.cells[4,3+(j-1)*2+3]:=ss1;
  163. Stringgrid1.cells[5,3+(j-1)*2+3]:=ss2;
  164. fx:=sumdx-dxteor;
  165. fy:=sumdy-dyteor;
  166. Str(fx:12:3,ss);
  167. Str(fy:12:3,ss1);
  168. Stringgrid1.cells[4,3+(j-1)*2+5]:=ss;
  169. Stringgrid1.cells[5,3+(j-1)*2+5]:=ss1;
  170. Stringgrid1.cells[4,3+(j-1)*2+4]:='Невязка Х';
  171. Stringgrid1.cells[5,3+(j-1)*2+4]:='Невязка Y';
  172. vx:=-fx/summas;
  173. vy:=-fy/summas;
  174. Str(vx:12:8,ss1);
  175. Str(vy:12:8,ss2);
  176. Stringgrid1.cells[4,3+(j-1)*2+6]:='Поправка X';
  177. Stringgrid1.cells[5,3+(j-1)*2+6]:='Поправка Y';
  178. Stringgrid1.cells[4,3+(j-1)*2+7]:=ss1;
  179. Stringgrid1.cells[5,3+(j-1)*2+7]:=ss2;
  180.  
  181. for j:=1 to i-1 do begin
  182.     if length(x) <= j then setLength(x, length(x)+1);
  183.     if length(y) <=j then setLength(y, length(y)+1);
  184.     x[j]:=x[j-1]+dx1[j-1]+vx*s1[j-1];
  185.     y[j]:=y[j-1]+dy1[j-1]+vy*s1[j-1];
  186.     Str(x[j]:12:3,ss1);
  187.     Str(y[j]:12:3,ss2);
  188.     Stringgrid1.cells[6,5+(j-1)*2]:=ss1;
  189.     Stringgrid1.cells[7,5+(j-1)*2]:=ss2;
  190. end; // j:=1 to i-1
  191. closefile(t);
  192. N8.Enabled:=true;
  193.   end;//opendialog
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement