unit Main;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ExtCtrls, ComCtrls, Menus, StdCtrls, Buttons, Grids;

type
  TMainForm = class(TForm)
    MainMenu: TMainMenu;
    File1: TMenuItem;
    New1: TMenuItem;
    Open1: TMenuItem;
    Save1: TMenuItem;
    Saveas1: TMenuItem;
    N1: TMenuItem;
    Exit1: TMenuItem;
    Help0: TMenuItem;
    Help1: TMenuItem;
    About1: TMenuItem;
    Timer: TTimer;
    Bevel: TBevel;
    View1: TMenuItem;
    ShowSpin: TMenuItem;
    ShowNumbersOfPoints: TMenuItem;
    Images: TMenuItem;
    Daons1: TMenuItem;
    Manager1: TMenuItem;
    Left1: TMenuItem;
    Right1: TMenuItem;
    Up1: TMenuItem;
    Down1: TMenuItem;
    OpenDialog: TOpenDialog;
    SaveDialog: TSaveDialog;
    MoveToCenter: TMenuItem;
    RusHelp: TMenuItem;
    PolHelp: TMenuItem;
    Pan: TPanel;
    Panel1: TPanel;
    DaoTeta1: TSpeedButton;
    DaoStop: TSpeedButton;
    DaoPsi: TSpeedButton;
    DaoPsi1: TSpeedButton;
    DaoTeta: TSpeedButton;
    DaoPhi1: TSpeedButton;
    DaoPhi: TSpeedButton;
    DaoForvard: TSpeedButton;
    DaoBack: TSpeedButton;
    ShapeLime: TShape;
    ShapeRed: TShape;
    LTime: TLabel;
    Label1: TLabel;
    DtLabel: TLabel;
    Null00: TSpeedButton;
    TrackBar: TTrackBar;
    Go: TBitBtn;
    ShowList: TCheckBox;
    EditDT: TEdit;
    FName: TEdit;
    PageControl: TPageControl;
    TabSheet1: TTabSheet;
    DaonsTable: TStringGrid;
    TabSheet2: TTabSheet;
    Comment: TMemo;
    EditA1: TEdit;
    EditB1: TEdit;
    EditC1: TEdit;
    EditD1: TEdit;
    EditF1: TEdit;
    EditA2: TEdit;
    EditB2: TEdit;
    EditC2: TEdit;
    EditD2: TEdit;
    EditF2: TEdit;
    EditA3: TEdit;
    EditB3: TEdit;
    EditC3: TEdit;
    EditD3: TEdit;
    EditF3: TEdit;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    Label10: TLabel;
    Label11: TLabel;
    Label6: TLabel;
   Label9: TLabel;
    Cool: TCheckBox;
    Label12: TLabel;
    Label13: TLabel;
    Label14: TLabel;
    Label15: TLabel;
    Label16: TLabel;
    EditG1: TEdit;
    EditG2: TEdit;
    EditG3: TEdit;
    Label17: TLabel;
    Label18: TLabel;
    Label19: TLabel;
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    RadioGroup2: TRadioGroup;
    Gravoscope: TRadioButton;
    Taoscope: TRadioButton;
    Functions3X1: TCheckBox;
    Blockade: TCheckBox;
    RadioGroup1: TRadioGroup;
    Stay0: TRadioButton;
    Stay1: TRadioButton;
    Stay2: TRadioButton;
    Stay3: TRadioButton;
    Stay4: TRadioButton;
    Stay5: TRadioButton;
    procedure Exit1Click(Sender: TObject);
    procedure FormPaint(Sender: TObject);
    procedure TimerTimer(Sender: TObject);
    procedure FormMouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure FormMouseUp(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure ShowSpinClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormResize(Sender: TObject);
    procedure DaoTeta1Click(Sender: TObject);
    procedure DaoTetaClick(Sender: TObject);
    procedure DaoPsiClick(Sender: TObject);
    procedure DaoPsi1Click(Sender: TObject);
    procedure DaoStopClick(Sender: TObject);
    procedure DaoPhi1Click(Sender: TObject);
    procedure DaoPhiClick(Sender: TObject);
    procedure DaoBackClick(Sender: TObject);
    procedure DaoForvardClick(Sender: TObject);
    procedure TrackBarChange(Sender: TObject);
    procedure ShowNumbersOfPointsClick(Sender: TObject);
    procedure Spiral1Click(Sender: TObject);
    procedure Daons1Click(Sender: TObject);
    procedure Left1Click(Sender: TObject);
    procedure Right1Click(Sender: TObject);
    procedure Up1Click(Sender: TObject);
    procedure Down1Click(Sender: TObject);
    procedure GoClick(Sender: TObject);
    procedure DaonsTableDblClick(Sender: TObject);
    procedure New1Click(Sender: TObject);
    procedure Open1Click(Sender: TObject);
    procedure Save1Click(Sender: TObject);
    procedure Saveas1Click(Sender: TObject);
    procedure MoveToCenterClick(Sender: TObject);
    procedure CommentChange(Sender: TObject);
    procedure CommentExit(Sender: TObject);
    procedure About1Click(Sender: TObject);
    procedure Help1Click(Sender: TObject);
    procedure RusHelpClick(Sender: TObject);
    procedure PolHelpClick(Sender: TObject);
    procedure EditDTKeyPress(Sender: TObject; var Key: Char);
    procedure EditA1KeyPress(Sender: TObject; var Key: Char);
    procedure EditB1KeyPress(Sender: TObject; var Key: Char);
    procedure EditC1KeyPress(Sender: TObject; var Key: Char);
    procedure EditD1KeyPress(Sender: TObject; var Key: Char);
    procedure EditF1KeyPress(Sender: TObject; var Key: Char);
    procedure EditG1KeyPress(Sender: TObject; var Key: Char);
    procedure EditA2KeyPress(Sender: TObject; var Key: Char);
    procedure EditB2KeyPress(Sender: TObject; var Key: Char);
    procedure EditC2KeyPress(Sender: TObject; var Key: Char);
    procedure EditD2KeyPress(Sender: TObject; var Key: Char);
    procedure EditF2KeyPress(Sender: TObject; var Key: Char);
    procedure EditG2KeyPress(Sender: TObject; var Key: Char);
    procedure EditA3KeyPress(Sender: TObject; var Key: Char);
    procedure EditB3KeyPress(Sender: TObject; var Key: Char);
    procedure EditC3KeyPress(Sender: TObject; var Key: Char);
    procedure EditD3KeyPress(Sender: TObject; var Key: Char);
    procedure EditF3KeyPress(Sender: TObject; var Key: Char);
    procedure EditG3KeyPress(Sender: TObject; var Key: Char);
    procedure EditDTExit(Sender: TObject);
    procedure EditA1Exit(Sender: TObject);
    procedure EditB1Exit(Sender: TObject);
    procedure EditC1Exit(Sender: TObject);
    procedure EditD1Exit(Sender: TObject);
    procedure EditF1Exit(Sender: TObject);
    procedure EditG1Exit(Sender: TObject);
    procedure EditA2Exit(Sender: TObject);
    procedure EditB2Exit(Sender: TObject);
    procedure EditC2Exit(Sender: TObject);
    procedure EditD2Exit(Sender: TObject);
    procedure EditF2Exit(Sender: TObject);
    procedure EditG2Exit(Sender: TObject);
    procedure EditA3Exit(Sender: TObject);
    procedure EditB3Exit(Sender: TObject);
    procedure EditC3Exit(Sender: TObject);
    procedure EditD3Exit(Sender: TObject);
    procedure EditF3Exit(Sender: TObject);
    procedure EditG3Exit(Sender: TObject);
    procedure Null00Click(Sender: TObject);
    procedure LTimeDblClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  MainForm: TMainForm;

implementation

{$N+}

uses Global, Figures, Edit, About;

{$R *.DFM}
const
     MaxK1= 90;
     MaxK2 = 10;
     MaxK3 = 900;
     MaxK4 = 100;
     MaxK5 = 250;
     MaxK6 = 100;
     MaxK7 = 60;
     MaxK8 = 2;

var
   //Power,             // Type of formula
   ShowLabelTime,
   EditComm,          // Comment is changed
   ShowNumbersOfPunkts,
   VeloCity,
   Spin               // Spin
                      :boolean;
   LStartX,LStartY,
   RStartX,RStartY
                      :integer;
   KoBok,             // Ñìåùåíèå âáîê
   KoRass,            // Koeff for length
   KoUgol             // Koeff
                      :extended;

procedure ClearCub;
begin
     with MainForm do
     with Canvas do
          begin
          Pen.Color:=clBlack;Brush.Color:=clBlack;
          Rectangle(Bevel.Left,Bevel.Top,Width,Pan.Top);
          end;
end;

procedure ShowTable;
var ii,jj:integer;
begin
with MainForm do
     with DaonsTable do
     if not VeloCity
     then
     begin
     Cells[1,0]:='X';Cells[2,0]:='Y';Cells[3,0]:='Z';
     for jj:=1 to MaxTaons do
         Cells[0,jj]:=IntToStr(jj);

     for ii := 1 to MaxTaons do
     for jj:= 1 to RowCount do
     if Dao[ii]
        then
        case jj of
         1:Cells[jj,ii] := FloatToStr(Xo[ii]);
         2:Cells[jj,ii] := FloatToStr(Yo[ii]);
         3:Cells[jj,ii] := FloatToStr(Zo[ii]);
        end
        else
            Cells[jj,ii] := '';
     end
     else
     begin
     Cells[1,0]:='u(x)';Cells[2,0]:='u(y)';Cells[3,0]:='u(z)';
     for jj:=1 to MaxTaons do
         Cells[0,jj]:=IntToStr(jj);

     for ii := 1 to MaxTaons do
     for jj:= 1 to RowCount do
     if Dao[ii]
        then
        case jj of
         1:Cells[jj,ii] := FloatToStr(Vo[ii]);
         2:Cells[jj,ii] := FloatToStr(Uo[ii]);
         3:Cells[jj,ii] := FloatToStr(Wo[ii]);
         end
        else
            Cells[jj,ii] := '';
     end;
end;
procedure DrawLine;
var n   :integer;
Ao1, B1, C1, D1, F1, G1, t, L1, L2, L3, L4, Xa, Za, Xb, Zb :extended;

begin    //1
Ffsincos;
  for n:=1 to MaxTaons do
  if Dao[n] then
      begin //2
          q:=f11*x[n]+f12*y[n]+f13*z[n];
          w:=f21*x[n]+f22*y[n]+f23*z[n];
          e:=f31*x[n]+f32*y[n]+f33*z[n];
          xs[n]:=q;ys[n]:=w;zs[n]:=e;
          xp:=xs[n]*xl/2;
          yp:=ys[n]*xl/2;
          zp:=zs[n]*xl/2;
          uu:=xp+u0+xt;
          vv:=zp+v0+zt;
          u[n]:=round(uu);v[n]:=round(vv);
      end; //2

ClearCub;
with MainForm do
     with Canvas do
          begin //2

             for n:=1 to MaxTaons do
             begin    //2a
                 if MainForm.Taoscope.Checked then
                     if Dao[n] then
                        begin  //3
                          if Odd(n) then
                          begin  //4
                          Pixels[u[n],v[n]]:=clRed;   //Fuchsia
                          Pixels[u[n]+1,v[n]]:=clRed;
                          Pixels[u[n],v[n]+1]:=clRed;
                          Pixels[u[n]+1,v[n]+1]:=clRed;
                          end     //4
                          else
                          begin     //4
                          Pixels[u[n],v[n]]:=clLime;  //Aqua;
                          Pixels[u[n]+1,v[n]]:=clLime;
                          Pixels[u[n],v[n]+1]:=clLime;
                          Pixels[u[n]+1,v[n]+1]:=clLime;
                          end;   //4
                       end;    //3

                 if MainForm.Gravoscope.Checked then
               //    for n:=1 to MaxTaons do
                     if Dao[n] then
                       begin //3
                          begin  //3a
                          if (n<=(MaxTaons-50)) then
                         begin   //4
                          Pixels[u[n],v[n]]:=clLime;
                          Pixels[u[n]+1,v[n]]:=clLime;
                          Pixels[u[n],v[n]+1]:=clLime;
                          Pixels[u[n]+1,v[n]+1]:=clLime;
                         end;     //4
                         end;   //3a
                     //   end;    //3
                          if ((n>(MaxTaons-50)) and (n<=(MaxTaons-25))) then
                         begin   //4
                          Pixels[u[n],v[n]]:=clYellow;
                          Pixels[u[n]+1,v[n]]:=clYellow;
                          Pixels[u[n],v[n]+1]:=clYellow;
                          Pixels[u[n]+1,v[n]+1]:=clYellow;
                         end;     //4
                          if (n>(MaxTaons-25)) then
                         begin     //4
                          Pixels[u[n],v[n]]:=clRed;
                          Pixels[u[n]+1,v[n]]:=clRed;
                          Pixels[u[n],v[n]+1]:=clRed;
                          Pixels[u[n]+1,v[n]+1]:=clRed;
                         end;     //4
                       end;    //3
             if MainForm.Taoscope.Checked then
                   if ShowNumbersOfPunkts then
           //          for n:=1 to MaxTaons do
                     if Dao[n] then
                       begin
                         if Odd(n) then
                         Font.Color:=clRed
                         else
                         Font.Color:=clLime;
                         TextOut(u[n]+2,v[n]+2,IntToStr(n));
                       end;
             if MainForm.Gravoscope.Checked then
                if ShowNumbersOfPunkts then
      //             for n:=1 to MaxTaons do
                     if Dao[n] then
                       begin
                         if (n<=(MaxTaons-50)) then
                         Font.Color:=clLime;
                         if ((n>(MaxTaons-50)) and (n<=(MaxTaons-25))) then
                         Font.Color:=clYellow;
                         if (n>(MaxTaons-25)) then
                         Font.Color:=clRed;
                         TextOut(u[n]+2,v[n]+2,IntToStr(n));
                       end;
                end;   //2a
          end;  //2
end;      //1
procedure ShowSpiral;
  procedure Proection(Maxn:integer);
  var n:integer;
  begin
  for n:=1 to Maxn do
      begin
          q:=f11*x[n]+f12*y[n]+f13*z[n];
          w:=f21*x[n]+f22*y[n]+f23*z[n];
          e:=f31*x[n]+f32*y[n]+f33*z[n];
          x[n]:=q;y[n]:=w;z[n]:=e;
          xp:=x[n]*xl/2;
          yp:=y[n]*xl/2;
          zp:=z[n]*xl/2;
          uu:=xp+u0+xt;
          vv:=zp+v0+zt;
          u[n]:=round(uu);v[n]:=round(vv);
      end;
  end;//Proection
begin
fsincos;
ClearCub;
with MainForm do
     with Canvas do
     case TypeSpiral of
     0:;
     1:
          begin
          Proection(19);
          Pen.Color:=clWhite;
          // first triangle
          moveto(u[1],v[1]);lineto(u[2],v[2]); // Axis
          Pen.Color:=clRed;
          lineto(u[3],v[3]);
          lineto(u[1],v[1]);
          // Tetra
          moveto(u[1],v[1]);lineto(u[4],v[4]);
          moveto(u[2],v[2]);lineto(u[4],v[4]);
          lineto(u[3],v[3]);lineto(u[4],v[4]);
          // 2-Tetra
          moveto(u[1],v[1]);lineto(u[5],v[5]);
          moveto(u[2],v[2]);lineto(u[5],v[5]);
          lineto(u[3],v[3]);lineto(u[5],v[5]);
          // 3-Tetra
          moveto(u[1],v[1]);lineto(u[6],v[6]);
          moveto(u[2],v[2]);lineto(u[6],v[6]);
          lineto(u[6],v[6]);lineto(u[5],v[5]);
          // 4-Tetra
          moveto(u[1],v[1]);lineto(u[7],v[7]);
          moveto(u[2],v[2]);lineto(u[7],v[7]);
          lineto(u[7],v[7]);lineto(u[6],v[6]);
          // 5-Tetra
          moveto(u[2],v[2]);lineto(u[8],v[8]);
          moveto(u[6],v[6]);lineto(u[8],v[8]);
          lineto(u[7],v[7]);lineto(u[8],v[8]);
          // 6-Tetra
          moveto(u[2],v[2]);lineto(u[9],v[9]);
          moveto(u[6],v[6]);lineto(u[9],v[9]);
          lineto(u[8],v[8]);lineto(u[9],v[9]);
          // 7-Tetra
          Pen.Color:=clWhite;  // Axis
          moveto(u[2],v[2]);lineto(u[10],v[10]);
          Pen.Color:=clRed;
          moveto(u[8],v[8]);lineto(u[10],v[10]);
          lineto(u[9],v[9]);lineto(u[10],v[10]);
          // 8-Tetra
          moveto(u[2],v[2]);lineto(u[11],v[11]);
          moveto(u[8],v[8]);lineto(u[11],v[11]);
          lineto(u[10],v[10]);lineto(u[11],v[11]);
          // 9-Tetra
          moveto(u[2],v[2]);lineto(u[12],v[12]);
          moveto(u[10],v[10]);lineto(u[12],v[12]);
          lineto(u[11],v[11]);lineto(u[12],v[12]);
          // 10-Tetra
          moveto(u[2],v[2]);lineto(u[13],v[13]);
          moveto(u[10],v[10]);lineto(u[13],v[13]);
          lineto(u[12],v[12]);lineto(u[13],v[13]);
          // 11-Tetra
          moveto(u[10],v[10]);lineto(u[14],v[14]);
          moveto(u[12],v[12]);lineto(u[14],v[14]);
          lineto(u[13],v[13]);lineto(u[14],v[14]);
          // 12-Tetra
          moveto(u[10],v[10]);lineto(u[15],v[15]);
          moveto(u[12],v[12]);lineto(u[15],v[15]);
          lineto(u[14],v[14]);lineto(u[15],v[15]);
          // 13-Tetra
          Pen.Color:=clWhite;  // Axis
          moveto(u[10],v[10]);lineto(u[16],v[16]);
          Pen.Color:=clRed;
          moveto(u[14],v[14]);lineto(u[16],v[16]);
          lineto(u[15],v[15]);lineto(u[16],v[16]);
          // 14-Tetra
          moveto(u[10],v[10]);lineto(u[17],v[17]);
          moveto(u[14],v[14]);lineto(u[17],v[17]);
          lineto(u[16],v[16]);lineto(u[17],v[17]);
          // 15-Tetra
          moveto(u[10],v[10]);lineto(u[18],v[18]);
          moveto(u[16],v[16]);lineto(u[18],v[18]);
          lineto(u[17],v[17]);lineto(u[18],v[18]);
          // 16-Tetra
          moveto(u[10],v[10]);lineto(u[19],v[19]);
          moveto(u[16],v[16]);lineto(u[19],v[19]);
          lineto(u[18],v[18]);lineto(u[19],v[19]);

          if ShowNumbersOfPunkts then
             begin
             Font.Color:=clLime;
             TextOut(u[1],v[1],'1');
             TextOut(u[2],v[2],'2');
             TextOut(u[3],v[3],'3');
             TextOut(u[4],v[4],'4');
             TextOut(u[5],v[5],'5');
             TextOut(u[6],v[6],'6');
             TextOut(u[7],v[7],'7');
             TextOut(u[8],v[8],'8');
             TextOut(u[9],v[9],'9');
             TextOut(u[10],v[10],'10');
             TextOut(u[11],v[11],'11');
             TextOut(u[12],v[12],'12');
             TextOut(u[13],v[13],'13');
             TextOut(u[14],v[14],'14');
             TextOut(u[15],v[15],'15');
             TextOut(u[16],v[16],'16');
             TextOut(u[17],v[17],'17');
             TextOut(u[18],v[18],'18');
             TextOut(u[19],v[19],'19');
             end;
          end;
     2:;
     3:;
     end;//case
end;//ShowSpiral
procedure Game(Num:Longint);
var Ky,Kz, Dzw, Pruw, Sr1, Sr2,
    Ysr11, Ysr12, Ysr13, Ysr14,
    Ysr15, Ysr16, Ysr17, Ysr18,
    Ysr21, Ysr22, Ysr23, Ysr24,
    Ysr25, Ysr26, Ysr27, Ysr28,
    Zkr, Ykr, Wkr, Ukr, Akat, Bkat, cs, sn
      (*Dzw, Ky, Kz, Pruw *) :extended;
   i                    // Number of partikle
                          :Longint;

   dXv, dYv, dZv,         // Prirashenie skorosti
   dX, dY, dZ             // Prirashenie koordinat
                          :extended;
   function GT :integer;
           begin
                if MainForm.Taoscope.Checked
                then
                GT:=1
                else
                GT:=-1;
           end;
   function Minus(im,jm:integer):integer;
   begin
     if Odd(im-jm) then
     Minus :=-1*GT
     else
     Minus := 1
   end;

   function ArcSin(X: Extended): Extended;
   begin
   end;
(*   function Pi: Extended;
   begin
   end;  *)

   function XUsko(im:integer):extended;
   // Poluchaem uskorenie po osi X
   var j :integer;
       Xia :extended;
       Ao1, Bo1, Co1, Do1, Fo1, Go1 :extended;
       Ao2, Bo2, Co2, Do2, Fo2, Go2 :extended;
       Ao3, Bo3, Co3, Do3, Fo3, Go3 :extended;
       m1, m2, m3, m4, m5,
       n1, n2, n3, n4, n5,
       p1c1, p1c2, p1c3,
       p2c1, p2c2, p2c3,
       p3c1, p3c2, p3c3, pd2e, pd2eg2, pd2eg3 :extended;
       s:extended;
   begin //1
   Xia:=0;
   Ao1:=A1;
   Bo1:=1.029/B1;
   Co1:=1.029/C1;
   Do1:=1.029/D1;
   Fo1:=1.029/F1;
   Go1:=1.029/G1;
   Ao2:=A2;
   Bo2:=1.029/B2;
   Co2:=1.029/C2;
   Do2:=1.029/D2;
   Fo2:=1.029/F2;
   Go2:=1.029/G2;
   Ao3:=A3;
   Bo3:=1.029/B3;
   Co3:=1.029/C3;
   Do3:=1.029/D3;
   Fo3:=1.029/F3;
   Go3:=1.029/G3;
   m1:=0.05;
   m2:=0.15;
   m3:=0.2;
   m4:=2;
   m5:=1.7;
   n1:=1;
   n2:=0.5;
   n3:=0.1;
   n4:=0.15;
   n5:=0.065;
   for j:=1 to MaxTaons do
    if Dao[j] then
     if j<>i then
      if MainForm.Functions3X1.Checked then
      begin   //2a
      begin //2
      s := Sqrt(Sqr(Xo[i]-Xo[j])+Sqr(Yo[i]-Yo[j])+Sqr(Zo[i]-Zo[j]));

       if (j<=(MaxTaons-50)) then
        begin //3
          p1c1:=0;(*-GT*(0.945/0.2)*St(18,(0.945/0.2)*s)
          *(1+19*ln((0.945/0.2)*s))*St(-St(19,(0.945/0.2)*s),(0.945/0.2)*s);*)
          p1c2:=-m1*( St(-1,n1*Bo1)* St(-2,s)*(2.5- St(20,Bo1*s))*(1-ln(Bo1*s))-200*Bo1*St(18,Bo1*s)
          *ln(Bo1*s))*St((2.5-St(20,Bo1*s))*St(-1,n1*Bo1*s),Bo1*s);

          p1c3:=-m2*( St(-1,n2*Co1)* St(-2,s)*(2.5- St(20,Co1*s))*(1-ln(Co1*s))-200*Co1*St(18,Co1*s)
          *ln(Co1*s))*St((2.5-St(20,Co1*s))*St(-1,n2*Co1*s),Co1*s)

          -m3*( St(-1,n3*Do1)* St(-2,s)*(2.5- St(20,Do1*s))*(1-ln(Do1*s))-200*Do1*St(18,Do1*s)
          *ln(Do1*s))*St((2.5-St(20,Do1*s))*St(-1,n3*Do1*s),Do1*s)

          -m4*( St(-1,n4*Fo1)* St(-2,s)*(2.5- St(20,Fo1*s))*(1-ln(Fo1*s))-200*Fo1*St(18,Fo1*s)
          *ln(Fo1*s))*St((2.5-St(20,Fo1*s))*St(-1,n4*Fo1*s),Fo1*s);
                begin  //4
                if (s<(G1)) then
                   begin  //5
                   pd2e:=0; // -0.5*m5* St(-1,2.72)*St(-2,({0.1*}G1-s))*Ao1 * {0.1*}G1 * exp(-0.5*St(-1,2.72)*{0.1*}G1/({0.1*}G1-s));
                   end;   //5
                if (s>(G1)) then
                   begin   //5
                   pd2e:= 0.5*m5* St(-1,2.72)*St(-2,(s-G1))*Ao1 * G1 * exp(-0.5*St(-1,2.72)*G1/(s-G1));
                   end;   //5
                end;     //4
         Xia := Xia +
         (*-1)*)GT*Minus(i,j)*(Xo[i]-Xo[j])/s * Ao1* (p1c1+p1c2+p1c3+pd2e);
        end; //3

       if ((j>(MaxTaons-50)) and (j<=(MaxTaons-25))) then
        begin  //3
          p2c1:=0;(*-GT*(0.945/0.2)*St(18,(0.945/0.2)*s)
          * (1+19*ln((0.945/0.2)*s))*St(-St(19,(0.945/0.2)*s),(0.945/0.2)*s);*)

          p2c2:=-m1*( St(-1,n1*Bo2)* St(-2,s)*(2.5- St(20,Bo2*s))*(1-ln(Bo2*s))-200*Bo2*St(18,Bo2*s)
          *ln(Bo2*s))*St((2.5-St(20,Bo2*s))*St(-1,n1*Bo2*s),Bo2*s);
          p2c3:=-m2*( St(-1,n2*Co2)* St(-2,s)*(2.5- St(20,Co2*s))*(1-ln(Co2*s))-200*Co2*St(18,Co2*s)
          *ln(Co2*s))*St((2.5-St(20,Co2*s))*St(-1,n2*Co2*s),Co2*s)

          -m3*( St(-1,n3*Do2)* St(-2,s)*(2.5- St(20,Do2*s))*(1-ln(Do2*s))-200*Do2*St(18,Do2*s)
          *ln(Do2*s))*St((2.5-St(20,Do2*s))*St(-1,n3*Do2*s),Do2*s)

          -m4*( St(-1,n4*Fo2)* St(-2,s)*(2.5- St(20,Fo2*s))*(1-ln(Fo2*s))-200*Fo2*St(18,Fo2*s)
          *ln(Fo2*s))*St((2.5-St(20,Fo2*s))*St(-1,n4*Fo2*s),Fo2*s);

                begin  //4
                if (s<(G2)) then
                   begin  //5
                   pd2eg2:=0; // -0.5*m5* St(-1,2.72)*St(-2,({0.1*}G2-s))*Ao2 * {0.1*}G2 * exp(-0.5*St(-1,2.72)*{0.1*}G2/({0.1*}G2-s));
                   end;   //5
                if (s>(G2)) then
                   begin   //5
                   pd2eg2:= 0.5*m5* St(-1,2.72)*St(-2,(s-G2))*Ao2 * G2 * exp(-0.5*St(-1,2.72)*G2/(s-G2));
                   end;   //5
                end;     //4
         Xia := Xia +
         (*-1)*)GT*Minus(i,j)*(Xo[i]-Xo[j])/s * Ao2* (p2c1+p2c2+p2c3+ pd2eg2);
        end; //3
       if (j>(MaxTaons-25)) then
        begin  //3
          p3c1:=0;(*-GT*(0.945/0.2)*St(18,(0.945/0.2)*s)
          * (1+19*ln((0.945/0.2)*s))*St(-St(19,(0.945/0.2)*s),(0.945/0.2)*s);*)

          p3c2:=-m1*( St(-1,n1*Bo3)* St(-2,s)*(2.5- St(20,Bo3*s))*(1-ln(Bo3*s))-200*Bo3*St(18,Bo3*s)
          *ln(Bo3*s))*St((2.5-St(20,Bo3*s))*St(-1,n1*Bo3*s),Bo3*s);
          p3c3:=-m2*( St(-1,n2*Co3)* St(-2,s)*(2.5- St(20,Co3*s))*(1-ln(Co3*s))-200*Co3*St(18,Co3*s)
          *ln(Co3*s))*St((2.5-St(20,Co3*s))*St(-1,n2*Co3*s),Co3*s)

          -m3*( St(-1,n3*Do3)* St(-2,s)*(2.5- St(20,Do3*s))*(1-ln(Do3*s))-200*Do3*St(18,Do3*s)
          *ln(Do3*s))*St((2.5-St(20,Do3*s))*St(-1,n3*Do3*s),Do3*s)

          -m4*( St(-1,n4*Fo3)* St(-2,s)*(2.5- St(20,Fo3*s))*(1-ln(Fo3*s))-200*Fo3*St(18,Fo3*s)
          *ln(Fo3*s))*St((2.5-St(20,Fo3*s))*St(-1,n4*Fo3*s),Fo3*s);

                begin  //4
                if (s<(G3)) then
                   begin  //5
                   pd2eg3:=0; // -0.5*m5* St(-1,2.72)*St(-2,({0.1*}G3-s))*Ao3 * {0.1*}G3 * exp(-0.5*St(-1,2.72)*{0.1*}G3/({0.1*}G3-s));
                   end;   //5
                if (s>(G3)) then
                   begin   //5
                   pd2eg3:= 0.5*m5* St(-1,2.72)*St(-2,(s-G3))*Ao3 * G3 * exp(-0.5*St(-1,2.72)*G3/(s-G3));
                   end;   //5
                end;     //4
         Xia := Xia +
         (*-1)*)GT*Minus(i,j)*(Xo[i]-Xo[j])/s * Ao3* (p3c1+p3c2+p3c3+pd2eg3);
        end; //3
      end;   //2
      end   //2a
      else
      begin //2a
      begin //2
      s := Sqrt(Sqr(Xo[i]-Xo[j])+Sqr(Yo[i]-Yo[j])+Sqr(Zo[i]-Zo[j]));
       begin  //2a
       if (j<=(MaxTaons-50)) then
        begin //3
          p1c1:=0;(*-GT*(0.945/0.2)*St(18,(0.945/0.2)*s)
          *(1+19*ln((0.945/0.2)*s))*St(-St(19,(0.945/0.2)*s),(0.945/0.2)*s);*)

          p1c2:=-m1*( St(-1,n1*Bo1)* St(-2,s)*(2.5- St(20,Bo1*s))*(1-ln(Bo1*s))-200*Bo1*St(18,Bo1*s)
          *ln(Bo1*s))*St((2.5-St(20,Bo1*s))*St(-1,n1*Bo1*s),Bo1*s);

          p1c3:=-m2*( St(-1,n2*Co1)* St(-2,s)*(2.5- St(20,Co1*s))*(1-ln(Co1*s))-200*Co1*St(18,Co1*s)
          *ln(Co1*s))*St((2.5-St(20,Co1*s))*St(-1,n2*Co1*s),Co1*s)

          -m3*( St(-1,n3*Do1)* St(-2,s)*(2.5- St(20,Do1*s))*(1-ln(Do1*s))-200*Do1*St(18,Do1*s)
          *ln(Do1*s))*St((2.5-St(20,Do1*s))*St(-1,n3*Do1*s),Do1*s)

          -m4*( St(-1,n4*Fo1)* St(-2,s)*(2.5- St(20,Fo1*s))*(1-ln(Fo1*s))-200*Fo1*St(18,Fo1*s)
          *ln(Fo1*s))*St((2.5-St(20,Fo1*s))*St(-1,n4*Fo1*s),Fo1*s);

          pd2e:=-m5*( St(-1,n5*Go1)* St(-2,s)*(2.5- St(20,Go1*s))*(1-ln(Go1*s))-200*Go1*St(18,Go1*s)
          *ln(Go1*s))*St((2.5-St(20,Go1*s))*St(-1,n5*Go1*s),Go1*s);

         Xia := Xia +
         (*-1)*)GT*Minus(i,j)*(Xo[i]-Xo[j])/s * Ao1* (p1c1+p1c2+p1c3+pd2e);
        end; //3
       end;   //2a

       if ((j>(MaxTaons-50)) and (j<=(MaxTaons-25))) then
        begin  //3
          p2c1:=0;(*-GT*(0.945/0.2)*St(18,(0.945/0.2)*s)
          * (1+19*ln((0.945/0.2)*s))*St(-St(19,(0.945/0.2)*s),(0.945/0.2)*s);*)

          p2c2:=-m1*( St(-1,n1*Bo2)* St(-2,s)*(2.5- St(20,Bo2*s))*(1-ln(Bo2*s))-200*Bo2*St(18,Bo2*s)
          *ln(Bo2*s))*St((2.5-St(20,Bo2*s))*St(-1,n1*Bo2*s),Bo2*s);
          p2c3:=-m2*( St(-1,n2*Co2)* St(-2,s)*(2.5- St(20,Co2*s))*(1-ln(Co2*s))-200*Co2*St(18,Co2*s)
          *ln(Co2*s))*St((2.5-St(20,Co2*s))*St(-1,n2*Co2*s),Co2*s)

          -m3*( St(-1,n3*Do2)* St(-2,s)*(2.5- St(20,Do2*s))*(1-ln(Do2*s))-200*Do2*St(18,Do2*s)
          *ln(Do2*s))*St((2.5-St(20,Do2*s))*St(-1,n3*Do2*s),Do2*s)

          -m4*( St(-1,n4*Fo2)* St(-2,s)*(2.5- St(20,Fo2*s))*(1-ln(Fo2*s))-200*Fo2*St(18,Fo2*s)
          *ln(Fo2*s))*St((2.5-St(20,Fo2*s))*St(-1,n4*Fo2*s),Fo2*s)

          -m5*( St(-1,n5*Go2)* St(-2,s)*(2.5- St(20,Go2*s))*(1-ln(Go2*s))-200*Go2*St(18,Go2*s)
          *ln(Go2*s))*St((2.5-St(20,Go2*s))*St(-1,n5*Go2*s),Go2*s);
         Xia := Xia +
         (*-1)*)GT*Minus(i,j)*(Xo[i]-Xo[j])/s * Ao2* (p2c1+p2c2+p2c3);
        end; //3
       if (j>(MaxTaons-25)) then
        begin  //3
          p3c1:=0;(*-GT*(0.945/0.2)*St(18,(0.945/0.2)*s)
          * (1+19*ln((0.945/0.2)*s))*St(-St(19,(0.945/0.2)*s),(0.945/0.2)*s);*)

          p3c2:=-m1*( St(-1,n1*Bo3)* St(-2,s)*(2.5- St(20,Bo3*s))*(1-ln(Bo3*s))-200*Bo3*St(18,Bo3*s)
          *ln(Bo3*s))*St((2.5-St(20,Bo3*s))*St(-1,n1*Bo3*s),Bo3*s);
          p3c3:=-m2*( St(-1,n2*Co3)* St(-2,s)*(2.5- St(20,Co3*s))*(1-ln(Co3*s))-200*Co3*St(18,Co3*s)
          *ln(Co3*s))*St((2.5-St(20,Co3*s))*St(-1,n2*Co3*s),Co3*s)

          -m3*( St(-1,n3*Do3)* St(-2,s)*(2.5- St(20,Do3*s))*(1-ln(Do3*s))-200*Do3*St(18,Do3*s)
          *ln(Do3*s))*St((2.5-St(20,Do3*s))*St(-1,n3*Do3*s),Do3*s)

          -m4*( St(-1,n4*Fo3)* St(-2,s)*(2.5- St(20,Fo3*s))*(1-ln(Fo3*s))-200*Fo3*St(18,Fo3*s)
          *ln(Fo3*s))*St((2.5-St(20,Fo3*s))*St(-1,n4*Fo3*s),Fo3*s)

          -m5*( St(-1,n5*Go3)* St(-2,s)*(2.5- St(20,Go3*s))*(1-ln(Go3*s))-200*Go3*St(18,Go3*s)
          *ln(Go3*s))*St((2.5-St(20,Go3*s))*St(-1,n5*Go3*s),Go3*s);
         Xia := Xia +
         (*-1)*)GT*Minus(i,j)*(Xo[i]-Xo[j])/s * Ao3* (p3c1+p3c2+p3c3);
        end; //3
      end;   //2
      end;   //2a
    XUsko:=Xia;
   end; //1
   function YUsko(im:integer):extended;
   // Poluchaem uskorenie po osi Y
   var j :integer;
       Yia :extended;
       Ao1, Bo1, Co1, Do1, Fo1, Go1 :extended;
       Ao2, Bo2, Co2, Do2, Fo2, Go2 :extended;
       Ao3, Bo3, Co3, Do3, Fo3, Go3 :extended;
       m1, m2, m3, m4, m5,
       n1, n2, n3, n4, n5,
       p1c1, p1c2, p1c3,
       p2c1, p2c2, p2c3,
       p3c1, p3c2, p3c3, pd2e, pd2eg2, pd2eg3 :extended;
       s:extended;
   begin //1
   Yia:=0;
   Ao1:=A1;
   Bo1:=1.029/B1;
   Co1:=1.029/C1;
   Do1:=1.029/D1;
   Fo1:=1.029/F1;
   Go1:=1.029/G1;
   Ao2:=A2;
   Bo2:=1.029/B2;
   Co2:=1.029/C2;
   Do2:=1.029/D2;
   Fo2:=1.029/F2;
   Go2:=1.029/G2;
   Ao3:=A3;
   Bo3:=1.029/B3;
   Co3:=1.029/C3;
   Do3:=1.029/D3;
   Fo3:=1.029/F3;
   Go3:=1.029/G3;
   m1:=0.05;
   m2:=0.15;
   m3:=0.2;
   m4:=2;
   m5:=1.7;
   n1:=1;
   n2:=0.5;
   n3:=0.1;
   n4:=0.15;
   n5:=0.065;
    for j:=1 to MaxTaons do
    if Dao[j] then
     if j<>i then
      if MainForm.Functions3X1.Checked then
      begin   //2a
      begin //2
      s := Sqrt(Sqr(Xo[i]-Xo[j])+Sqr(Yo[i]-Yo[j])+Sqr(Zo[i]-Zo[j]));

       if (j<=(MaxTaons-50)) then
        begin //3
          p1c1:=0;(*-GT*(0.945/0.2)*St(18,(0.945/0.2)*s)
          *(1+19*ln((0.945/0.2)*s))*St(-St(19,(0.945/0.2)*s),(0.945/0.2)*s);*)
          p1c2:=-m1*( St(-1,n1*Bo1)* St(-2,s)*(2.5- St(20,Bo1*s))*(1-ln(Bo1*s))-200*Bo1*St(18,Bo1*s)
          *ln(Bo1*s))*St((2.5-St(20,Bo1*s))*St(-1,n1*Bo1*s),Bo1*s);

          p1c3:=-m2*( St(-1,n2*Co1)* St(-2,s)*(2.5- St(20,Co1*s))*(1-ln(Co1*s))-200*Co1*St(18,Co1*s)
          *ln(Co1*s))*St((2.5-St(20,Co1*s))*St(-1,n2*Co1*s),Co1*s)

          -m3*( St(-1,n3*Do1)* St(-2,s)*(2.5- St(20,Do1*s))*(1-ln(Do1*s))-200*Do1*St(18,Do1*s)
          *ln(Do1*s))*St((2.5-St(20,Do1*s))*St(-1,n3*Do1*s),Do1*s)

          -m4*( St(-1,n4*Fo1)* St(-2,s)*(2.5- St(20,Fo1*s))*(1-ln(Fo1*s))-200*Fo1*St(18,Fo1*s)
          *ln(Fo1*s))*St((2.5-St(20,Fo1*s))*St(-1,n4*Fo1*s),Fo1*s);
                begin  //4
                if (s<(G1)) then
                   begin  //5
                   pd2e:=0; // -0.5*m5* St(-1,2.72)*St(-2,({0.1*}G1-s))*Ao1 * {0.1*}G1 * exp(-0.5*St(-1,2.72)*{0.1*}G1/({0.1*}G1-s));
                   end;   //5
                if (s>(G1)) then
                   begin   //5
                   pd2e:= 0.5*m5* St(-1,2.72)*St(-2,(s-G1))*Ao1 * G1 * exp(-0.5*St(-1,2.72)*G1/(s-G1));
                   end;   //5
                end;     //4
         Yia := Yia +
         (*-1)*)GT*Minus(i,j)*(Yo[i]-Yo[j])/s * Ao1* (p1c1+p1c2+p1c3+pd2e);
        end; //3

       if ((j>(MaxTaons-50)) and (j<=(MaxTaons-25))) then
        begin  //3
          p2c1:=0;(*-GT*(0.945/0.2)*St(18,(0.945/0.2)*s)
          * (1+19*ln((0.945/0.2)*s))*St(-St(19,(0.945/0.2)*s),(0.945/0.2)*s);*)

          p2c2:=-m1*( St(-1,n1*Bo2)* St(-2,s)*(2.5- St(20,Bo2*s))*(1-ln(Bo2*s))-200*Bo2*St(18,Bo2*s)
          *ln(Bo2*s))*St((2.5-St(20,Bo2*s))*St(-1,n1*Bo2*s),Bo2*s);
          p2c3:=-m2*( St(-1,n2*Co2)* St(-2,s)*(2.5- St(20,Co2*s))*(1-ln(Co2*s))-200*Co2*St(18,Co2*s)
          *ln(Co2*s))*St((2.5-St(20,Co2*s))*St(-1,n2*Co2*s),Co2*s)

          -m3*( St(-1,n3*Do2)* St(-2,s)*(2.5- St(20,Do2*s))*(1-ln(Do2*s))-200*Do2*St(18,Do2*s)
          *ln(Do2*s))*St((2.5-St(20,Do2*s))*St(-1,n3*Do2*s),Do2*s)

          -m4*( St(-1,n4*Fo2)* St(-2,s)*(2.5- St(20,Fo2*s))*(1-ln(Fo2*s))-200*Fo2*St(18,Fo2*s)
          *ln(Fo2*s))*St((2.5-St(20,Fo2*s))*St(-1,n4*Fo2*s),Fo2*s);

                begin  //4
                if (s<(G2)) then
                   begin  //5
                   pd2eg2:=0; // -0.5*m5* St(-1,2.72)*St(-2,({0.1*}G2-s))*Ao2 * {0.1*}G2 * exp(-0.5*St(-1,2.72)*{0.1*}G2/({0.1*}G2-s));
                   end;   //5
                if (s>(G2)) then
                   begin   //5
                   pd2eg2:= 0.5*m5* St(-1,2.72)*St(-2,(s-G2))*Ao2 * G2 * exp(-0.5*St(-1,2.72)*G2/(s-G2));
                   end;   //5
                end;     //4
         Yia := Yia +
         (*-1)*)GT*Minus(i,j)*(Yo[i]-Yo[j])/s * Ao2* (p2c1+p2c2+p2c3+ pd2eg2);
        end; //3
       if (j>(MaxTaons-25)) then
        begin  //3
          p3c1:=0;(*-GT*(0.945/0.2)*St(18,(0.945/0.2)*s)
          * (1+19*ln((0.945/0.2)*s))*St(-St(19,(0.945/0.2)*s),(0.945/0.2)*s);*)

          p3c2:=-m1*( St(-1,n1*Bo3)* St(-2,s)*(2.5- St(20,Bo3*s))*(1-ln(Bo3*s))-200*Bo3*St(18,Bo3*s)
          *ln(Bo3*s))*St((2.5-St(20,Bo3*s))*St(-1,n1*Bo3*s),Bo3*s);
          p3c3:=-m2*( St(-1,n2*Co3)* St(-2,s)*(2.5- St(20,Co3*s))*(1-ln(Co3*s))-200*Co3*St(18,Co3*s)
          *ln(Co3*s))*St((2.5-St(20,Co3*s))*St(-1,n2*Co3*s),Co3*s)

          -m3*( St(-1,n3*Do3)* St(-2,s)*(2.5- St(20,Do3*s))*(1-ln(Do3*s))-200*Do3*St(18,Do3*s)
          *ln(Do3*s))*St((2.5-St(20,Do3*s))*St(-1,n3*Do3*s),Do3*s)

          -m4*( St(-1,n4*Fo3)* St(-2,s)*(2.5- St(20,Fo3*s))*(1-ln(Fo3*s))-200*Fo3*St(18,Fo3*s)
          *ln(Fo3*s))*St((2.5-St(20,Fo3*s))*St(-1,n4*Fo3*s),Fo3*s);

                begin  //4
                if (s<(G3)) then
                   begin  //5
                   pd2eg3:=0; // -0.5*m5* St(-1,2.72)*St(-2,({0.1*}G3-s))*Ao3 * {0.1*}G3 * exp(-0.5*St(-1,2.72)*{0.1*}G3/({0.1*}G3-s));
                   end;   //5
                if (s>(G3)) then
                   begin   //5
                   pd2eg3:= 0.5*m5* St(-1,2.72)*St(-2,(s-G3))*Ao3 * G3 * exp(-0.5*St(-1,2.72)*G3/(s-G3));
                   end;   //5
                end;     //4
         Yia := Yia +
         (*-1)*)GT*Minus(i,j)*(Yo[i]-Yo[j])/s * Ao3* (p3c1+p3c2+p3c3+pd2eg3);
        end; //3
      end;   //2
      end   //2a
      else
      begin //2a
      begin //2
      s := Sqrt(Sqr(Xo[i]-Xo[j])+Sqr(Yo[i]-Yo[j])+Sqr(Zo[i]-Zo[j]));

       begin  //2a
       if (j<=(MaxTaons-50)) then
        begin //3
          p1c1:=0;(*-GT*(0.945/0.2)*St(18,(0.945/0.2)*s)
          *(1+19*ln((0.945/0.2)*s))*St(-St(19,(0.945/0.2)*s),(0.945/0.2)*s);*)

          p1c2:=-m1*( St(-1,n1*Bo1)* St(-2,s)*(2.5- St(20,Bo1*s))*(1-ln(Bo1*s))-200*Bo1*St(18,Bo1*s)
          *ln(Bo1*s))*St((2.5-St(20,Bo1*s))*St(-1,n1*Bo1*s),Bo1*s);

          p1c3:=-m2*( St(-1,n2*Co1)* St(-2,s)*(2.5- St(20,Co1*s))*(1-ln(Co1*s))-200*Co1*St(18,Co1*s)
          *ln(Co1*s))*St((2.5-St(20,Co1*s))*St(-1,n2*Co1*s),Co1*s)

          -m3*( St(-1,n3*Do1)* St(-2,s)*(2.5- St(20,Do1*s))*(1-ln(Do1*s))-200*Do1*St(18,Do1*s)
          *ln(Do1*s))*St((2.5-St(20,Do1*s))*St(-1,n3*Do1*s),Do1*s)

          -m4*( St(-1,n4*Fo1)* St(-2,s)*(2.5- St(20,Fo1*s))*(1-ln(Fo1*s))-200*Fo1*St(18,Fo1*s)
          *ln(Fo1*s))*St((2.5-St(20,Fo1*s))*St(-1,n4*Fo1*s),Fo1*s);

          pd2e:=-m5*( St(-1,n5*Go1)* St(-2,s)*(2.5- St(20,Go1*s))*(1-ln(Go1*s))-200*Go1*St(18,Go1*s)
          *ln(Go1*s))*St((2.5-St(20,Go1*s))*St(-1,n5*Go1*s),Go1*s);

         Yia := Yia +
         (*-1)*)GT*Minus(i,j)*(Yo[i]-Yo[j])/s * Ao1* (p1c1+p1c2+p1c3+pd2e);
        end; //3
       end;   //2a

       if ((j>(MaxTaons-50)) and (j<=(MaxTaons-25))) then
        begin  //3
          p2c1:=0;(*-GT*(0.945/0.2)*St(18,(0.945/0.2)*s)
          * (1+19*ln((0.945/0.2)*s))*St(-St(19,(0.945/0.2)*s),(0.945/0.2)*s);*)

          p2c2:=-m1*( St(-1,n1*Bo2)* St(-2,s)*(2.5- St(20,Bo2*s))*(1-ln(Bo2*s))-200*Bo2*St(18,Bo2*s)
          *ln(Bo2*s))*St((2.5-St(20,Bo2*s))*St(-1,n1*Bo2*s),Bo2*s);

          p2c3:=-m2*( St(-1,n2*Co2)* St(-2,s)*(2.5- St(20,Co2*s))*(1-ln(Co2*s))-200*Co2*St(18,Co2*s)
          *ln(Co2*s))*St((2.5-St(20,Co2*s))*St(-1,n2*Co2*s),Co2*s)

          -m3*( St(-1,n3*Do2)* St(-2,s)*(2.5- St(20,Do2*s))*(1-ln(Do2*s))-200*Do2*St(18,Do2*s)
          *ln(Do2*s))*St((2.5-St(20,Do2*s))*St(-1,n3*Do2*s),Do2*s)

          -m4*( St(-1,n4*Fo2)* St(-2,s)*(2.5- St(20,Fo2*s))*(1-ln(Fo2*s))-200*Fo2*St(18,Fo2*s)
          *ln(Fo2*s))*St((2.5-St(20,Fo2*s))*St(-1,n4*Fo2*s),Fo2*s)

          -m5*( St(-1,n5*Go2)* St(-2,s)*(2.5- St(20,Go2*s))*(1-ln(Go2*s))-200*Go2*St(18,Go2*s)
          *ln(Go2*s))*St((2.5-St(20,Go2*s))*St(-1,n5*Go2*s),Go2*s);
         Yia := Yia +
         (*-1)*)GT*Minus(i,j)*(Yo[i]-Yo[j])/s * Ao2* (p2c1+p2c2+p2c3);
        end; //3
       if (j>(MaxTaons-25)) then
        begin  //3
          p3c1:=0;(*-GT*(0.945/0.2)*St(18,(0.945/0.2)*s)
          * (1+19*ln((0.945/0.2)*s))*St(-St(19,(0.945/0.2)*s),(0.945/0.2)*s);*)

          p3c2:=-m1*( St(-1,n1*Bo3)* St(-2,s)*(2.5- St(20,Bo3*s))*(1-ln(Bo3*s))-200*Bo3*St(18,Bo3*s)
          *ln(Bo3*s))*St((2.5-St(20,Bo3*s))*St(-1,n1*Bo3*s),Bo3*s);
          p3c3:=-m2*( St(-1,n2*Co3)* St(-2,s)*(2.5- St(20,Co3*s))*(1-ln(Co3*s))-200*Co3*St(18,Co3*s)
          *ln(Co3*s))*St((2.5-St(20,Co3*s))*St(-1,n2*Co3*s),Co3*s)

          -m3*( St(-1,n3*Do3)* St(-2,s)*(2.5- St(20,Do3*s))*(1-ln(Do3*s))-200*Do3*St(18,Do3*s)
          *ln(Do3*s))*St((2.5-St(20,Do3*s))*St(-1,n3*Do3*s),Do3*s)

          -m4*( St(-1,n4*Fo3)* St(-2,s)*(2.5- St(20,Fo3*s))*(1-ln(Fo3*s))-200*Fo3*St(18,Fo3*s)
          *ln(Fo3*s))*St((2.5-St(20,Fo3*s))*St(-1,n4*Fo3*s),Fo3*s)

          -m5*( St(-1,n5*Go3)* St(-2,s)*(2.5- St(20,Go3*s))*(1-ln(Go3*s))-200*Go3*St(18,Go3*s)
          *ln(Go3*s))*St((2.5-St(20,Go3*s))*St(-1,n5*Go3*s),Go3*s);
         Yia := Yia +
         (*-1)*)GT*Minus(i,j)*(Yo[i]-Yo[j])/s * Ao3* (p3c1+p3c2+p3c3);
        end; //3
      end;   //2
      end;  //2a
    YUsko:=Yia;
   end; //1

   function ZUsko(im:integer):extended;
   // Poluchaem uskorenie po osi Z
   var j :integer;
       Zia :extended;
       Ao1, Bo1, Co1, Do1, Fo1, Go1 :extended;
       Ao2, Bo2, Co2, Do2, Fo2, Go2 :extended;
       Ao3, Bo3, Co3, Do3, Fo3, Go3 :extended;
       m1, m2, m3, m4, m5,
       n1, n2, n3, n4, n5,
       p1c1, p1c2, p1c3,
       p2c1, p2c2, p2c3,
       p3c1, p3c2, p3c3, pd2e,pd2eg2, pd2eg3 :extended;
       s:extended;
   begin //1
   Zia:=0;
   Ao1:=A1;
   Bo1:=1.029/B1;
   Co1:=1.029/C1;
   Do1:=1.029/D1;
   Fo1:=1.029/F1;
   Go1:=1.029/G1;
   Ao2:=A2;
   Bo2:=1.029/B2;
   Co2:=1.029/C2;
   Do2:=1.029/D2;
   Fo2:=1.029/F2;
   Go2:=1.029/G2;
   Ao3:=A3;
   Bo3:=1.029/B3;
   Co3:=1.029/C3;
   Do3:=1.029/D3;
   Fo3:=1.029/F3;
   Go3:=1.029/G3;
   m1:=0.05;
   m2:=0.15;
   m3:=0.2;
   m4:=2;
   m5:=1.7;
   n1:=1;
   n2:=0.5;
   n3:=0.1;
   n4:=0.15;
   n5:=0.065;
   for j:=1 to MaxTaons do
    if Dao[j] then
     if j<>i then
      if MainForm.Functions3X1.Checked then
      begin   //2a
      begin //2
      s := Sqrt(Sqr(Xo[i]-Xo[j])+Sqr(Yo[i]-Yo[j])+Sqr(Zo[i]-Zo[j]));

       if (j<=(MaxTaons-50)) then
        begin //3
          p1c1:=0;(*-GT*(0.945/0.2)*St(18,(0.945/0.2)*s)
          *(1+19*ln((0.945/0.2)*s))*St(-St(19,(0.945/0.2)*s),(0.945/0.2)*s);*)
          p1c2:=-m1*( St(-1,n1*Bo1)* St(-2,s)*(2.5- St(20,Bo1*s))*(1-ln(Bo1*s))-200*Bo1*St(18,Bo1*s)
          *ln(Bo1*s))*St((2.5-St(20,Bo1*s))*St(-1,n1*Bo1*s),Bo1*s);

          p1c3:=-m2*( St(-1,n2*Co1)* St(-2,s)*(2.5- St(20,Co1*s))*(1-ln(Co1*s))-200*Co1*St(18,Co1*s)
          *ln(Co1*s))*St((2.5-St(20,Co1*s))*St(-1,n2*Co1*s),Co1*s)

          -m3*( St(-1,n3*Do1)* St(-2,s)*(2.5- St(20,Do1*s))*(1-ln(Do1*s))-200*Do1*St(18,Do1*s)
          *ln(Do1*s))*St((2.5-St(20,Do1*s))*St(-1,n3*Do1*s),Do1*s)

          -m4*( St(-1,n4*Fo1)* St(-2,s)*(2.5- St(20,Fo1*s))*(1-ln(Fo1*s))-200*Fo1*St(18,Fo1*s)
          *ln(Fo1*s))*St((2.5-St(20,Fo1*s))*St(-1,n4*Fo1*s),Fo1*s);
                begin  //4
                if (s<(G1)) then
                   begin  //5
                   pd2e:=0; // -0.5*m5* St(-1,2.72)*St(-2,({0.1*}G1-s))*Ao1 * {0.1*}G1 * exp(-0.5*St(-1,2.72)*{0.1*}G1/({0.1*}G1-s));
                   end;   //5
                if (s>(G1)) then
                   begin   //5
                   pd2e:= 0.5*m5* St(-1,2.72)*St(-2,(s-G1))*Ao1 * G1 * exp(-0.5*St(-1,2.72)*G1/(s-G1));
                   end;   //5
                end;     //4
         Zia := Zia +
         (*-1)*)GT*Minus(i,j)*(Zo[i]-Zo[j])/s * Ao1* (p1c1+p1c2+p1c3+pd2e);
        end; //3

       if ((j>(MaxTaons-50)) and (j<=(MaxTaons-25))) then
        begin  //3
          p2c1:=0;(*-GT*(0.945/0.2)*St(18,(0.945/0.2)*s)
          * (1+19*ln((0.945/0.2)*s))*St(-St(19,(0.945/0.2)*s),(0.945/0.2)*s);*)

          p2c2:=-m1*( St(-1,n1*Bo2)* St(-2,s)*(2.5- St(20,Bo2*s))*(1-ln(Bo2*s))-200*Bo2*St(18,Bo2*s)
          *ln(Bo2*s))*St((2.5-St(20,Bo2*s))*St(-1,n1*Bo2*s),Bo2*s);
          p2c3:=-m2*( St(-1,n2*Co2)* St(-2,s)*(2.5- St(20,Co2*s))*(1-ln(Co2*s))-200*Co2*St(18,Co2*s)
          *ln(Co2*s))*St((2.5-St(20,Co2*s))*St(-1,n2*Co2*s),Co2*s)

          -m3*( St(-1,n3*Do2)* St(-2,s)*(2.5- St(20,Do2*s))*(1-ln(Do2*s))-200*Do2*St(18,Do2*s)
          *ln(Do2*s))*St((2.5-St(20,Do2*s))*St(-1,n3*Do2*s),Do2*s)

          -m4*( St(-1,n4*Fo2)* St(-2,s)*(2.5- St(20,Fo2*s))*(1-ln(Fo2*s))-200*Fo2*St(18,Fo2*s)
          *ln(Fo2*s))*St((2.5-St(20,Fo2*s))*St(-1,n4*Fo2*s),Fo2*s);

                begin  //4
                if (s<(G2)) then
                   begin  //5
                   pd2eg2:=0; // -0.5*m5* St(-1,2.72)*St(-2,({0.1*}G2-s))*Ao2 * {0.1*}G2 * exp(-0.5*St(-1,2.72)*{0.1*}G2/({0.1*}G2-s));
                   end;   //5
                if (s>(G2)) then
                   begin   //5
                   pd2eg2:= 0.5*m5* St(-1,2.72)*St(-2,(s-G2))*Ao2 * G2 * exp(-0.5*St(-1,2.72)*G2/(s-G2));
                   end;   //5
                end;     //4
         Zia := Zia +
         (*-1)*)GT*Minus(i,j)*(Zo[i]-Zo[j])/s * Ao2* (p2c1+p2c2+p2c3+ pd2eg2);
        end; //3
       if (j>(MaxTaons-25)) then
        begin  //3
          p3c1:=0;(*-GT*(0.945/0.2)*St(18,(0.945/0.2)*s)
          * (1+19*ln((0.945/0.2)*s))*St(-St(19,(0.945/0.2)*s),(0.945/0.2)*s);*)

          p3c2:=-m1*( St(-1,n1*Bo3)* St(-2,s)*(2.5- St(20,Bo3*s))*(1-ln(Bo3*s))-200*Bo3*St(18,Bo3*s)
          *ln(Bo3*s))*St((2.5-St(20,Bo3*s))*St(-1,n1*Bo3*s),Bo3*s);
          p3c3:=-m2*( St(-1,n2*Co3)* St(-2,s)*(2.5- St(20,Co3*s))*(1-ln(Co3*s))-200*Co3*St(18,Co3*s)
          *ln(Co3*s))*St((2.5-St(20,Co3*s))*St(-1,n2*Co3*s),Co3*s)

          -m3*( St(-1,n3*Do3)* St(-2,s)*(2.5- St(20,Do3*s))*(1-ln(Do3*s))-200*Do3*St(18,Do3*s)
          *ln(Do3*s))*St((2.5-St(20,Do3*s))*St(-1,n3*Do3*s),Do3*s)

          -m4*( St(-1,n4*Fo3)* St(-2,s)*(2.5- St(20,Fo3*s))*(1-ln(Fo3*s))-200*Fo3*St(18,Fo3*s)
          *ln(Fo3*s))*St((2.5-St(20,Fo3*s))*St(-1,n4*Fo3*s),Fo3*s);

                begin  //4
                if (s<(G3)) then
                   begin  //5
                   pd2eg3:=0; // -0.5*m5* St(-1,2.72)*St(-2,({0.1*}G3-s))*Ao3 * {0.1*}G3 * exp(-0.5*St(-1,2.72)*{0.1*}G3/({0.1*}G3-s));
                   end;   //5
                if (s>(G3)) then
                   begin   //5
                   pd2eg3:= 0.5*m5* St(-1,2.72)*St(-2,(s-G3))*Ao3 * G3 * exp(-0.5*St(-1,2.72)*G3/(s-G3));
                   end;   //5
                end;     //4
         Zia := Zia +
         (*-1)*)GT*Minus(i,j)*(Zo[i]-Zo[j])/s * Ao3* (p3c1+p3c2+p3c3+pd2eg3);
        end; //3
      end;   //2
      end   //2a
      else
      begin //2a
      begin //2
      s := Sqrt(Sqr(Xo[i]-Xo[j])+Sqr(Yo[i]-Yo[j])+Sqr(Zo[i]-Zo[j]));

       begin   //2a
       if (j<=(MaxTaons-50)) then
        begin //3
          p1c1:=0;(*-GT*(0.945/0.2)*St(18,(0.945/0.2)*s)
          *(1+19*ln((0.945/0.2)*s))*St(-St(19,(0.945/0.2)*s),(0.945/0.2)*s);*)

          p1c2:=-m1*( St(-1,n1*Bo1)* St(-2,s)*(2.5- St(20,Bo1*s))*(1-ln(Bo1*s))-200*Bo1*St(18,Bo1*s)
          *ln(Bo1*s))*St((2.5-St(20,Bo1*s))*St(-1,n1*Bo1*s),Bo1*s);

          p1c3:=-m2*( St(-1,n2*Co1)* St(-2,s)*(2.5- St(20,Co1*s))*(1-ln(Co1*s))-200*Co1*St(18,Co1*s)
          *ln(Co1*s))*St((2.5-St(20,Co1*s))*St(-1,n2*Co1*s),Co1*s)

          -m3*( St(-1,n3*Do1)* St(-2,s)*(2.5- St(20,Do1*s))*(1-ln(Do1*s))-200*Do1*St(18,Do1*s)
          *ln(Do1*s))*St((2.5-St(20,Do1*s))*St(-1,n3*Do1*s),Do1*s)

          -m4*( St(-1,n4*Fo1)* St(-2,s)*(2.5- St(20,Fo1*s))*(1-ln(Fo1*s))-200*Fo1*St(18,Fo1*s)
          *ln(Fo1*s))*St((2.5-St(20,Fo1*s))*St(-1,n4*Fo1*s),Fo1*s);

          pd2e:=-m5*( St(-1,n5*Go1)* St(-2,s)*(2.5- St(20,Go1*s))*(1-ln(Go1*s))-200*Go1*St(18,Go1*s)
          *ln(Go1*s))*St((2.5-St(20,Go1*s))*St(-1,n5*Go1*s),Go1*s);

         Zia := Zia +
         (*-1)*)GT*Minus(i,j)*(Zo[i]-Zo[j])/s * Ao1* (p1c1+p1c2+p1c3+pd2e);
        end; //3
       end;    //2a
       if ((j>(MaxTaons-50)) and (j<=(MaxTaons-25))) then
        begin  //3
          p2c1:=0;(*-GT*(0.945/0.2)*St(18,(0.945/0.2)*s)
          * (1+19*ln((0.945/0.2)*s))*St(-St(19,(0.945/0.2)*s),(0.945/0.2)*s);*)

          p2c2:=-m1*( St(-1,n1*Bo2)* St(-2,s)*(2.5- St(20,Bo2*s))*(1-ln(Bo2*s))-200*Bo2*St(18,Bo2*s)
          *ln(Bo2*s))*St((2.5-St(20,Bo2*s))*St(-1,n1*Bo2*s),Bo2*s);
          p2c3:=-m2*( St(-1,n2*Co2)* St(-2,s)*(2.5- St(20,Co2*s))*(1-ln(Co2*s))-200*Co2*St(18,Co2*s)
          *ln(Co2*s))*St((2.5-St(20,Co2*s))*St(-1,n2*Co2*s),Co2*s)

          -m3*( St(-1,n3*Do2)* St(-2,s)*(2.5- St(20,Do2*s))*(1-ln(Do2*s))-200*Do2*St(18,Do2*s)
          *ln(Do2*s))*St((2.5-St(20,Do2*s))*St(-1,n3*Do2*s),Do2*s)

          -m4*( St(-1,n4*Fo2)* St(-2,s)*(2.5- St(20,Fo2*s))*(1-ln(Fo2*s))-200*Fo2*St(18,Fo2*s)
          *ln(Fo2*s))*St((2.5-St(20,Fo2*s))*St(-1,n4*Fo2*s),Fo2*s)

          -m5*( St(-1,n5*Go2)* St(-2,s)*(2.5- St(20,Go2*s))*(1-ln(Go2*s))-200*Go2*St(18,Go2*s)
          *ln(Go2*s))*St((2.5-St(20,Go2*s))*St(-1,n5*Go2*s),Go2*s);
         Zia := Zia +
         (*-1)*)GT*Minus(i,j)*(Zo[i]-Zo[j])/s * Ao2* (p2c1+p2c2+p2c3);
        end; //3
       if (j>(MaxTaons-25)) then
        begin  //3
          p3c1:=0;(*-GT*(0.945/0.2)*St(18,(0.945/0.2)*s)
          * (1+19*ln((0.945/0.2)*s))*St(-St(19,(0.945/0.2)*s),(0.945/0.2)*s);*)

          p3c2:=-m1*( St(-1,n1*Bo3)* St(-2,s)*(2.5- St(20,Bo3*s))*(1-ln(Bo3*s))-200*Bo3*St(18,Bo3*s)
          *ln(Bo3*s))*St((2.5-St(20,Bo3*s))*St(-1,n1*Bo3*s),Bo3*s);
          p3c3:=-m2*( St(-1,n2*Co3)* St(-2,s)*(2.5- St(20,Co3*s))*(1-ln(Co3*s))-200*Co3*St(18,Co3*s)
          *ln(Co3*s))*St((2.5-St(20,Co3*s))*St(-1,n2*Co3*s),Co3*s)

          -m3*( St(-1,n3*Do3)* St(-2,s)*(2.5- St(20,Do3*s))*(1-ln(Do3*s))-200*Do3*St(18,Do3*s)
          *ln(Do3*s))*St((2.5-St(20,Do3*s))*St(-1,n3*Do3*s),Do3*s)

          -m4*( St(-1,n4*Fo3)* St(-2,s)*(2.5- St(20,Fo3*s))*(1-ln(Fo3*s))-200*Fo3*St(18,Fo3*s)
          *ln(Fo3*s))*St((2.5-St(20,Fo3*s))*St(-1,n4*Fo3*s),Fo3*s)

          -m5*( St(-1,n5*Go3)* St(-2,s)*(2.5- St(20,Go3*s))*(1-ln(Go3*s))-200*Go3*St(18,Go3*s)
          *ln(Go3*s))*St((2.5-St(20,Go3*s))*St(-1,n5*Go3*s),Go3*s);
         Zia := Zia +
         (*-1)*)GT*Minus(i,j)*(Zo[i]-Zo[j])/s * Ao3* (p3c1+p3c2+p3c3);
        end; //3
      end;   //2
      end;   //2a
    ZUsko:=Zia;
   end; //1
function Co :extended;
   begin
     if MainForm.Cool.Checked  then
       Co:=0.99
     else
       Co:=1;
   end;
begin // Game //
repeat
   inc(Num);

   // Calculation of new value of koord and velo.
//******************************
         if MainForm.Blockade.Checked  then
         begin     //3
   // Calculation of new value of koord and velo.
             for i:=1 to (MaxTaons-30) do
             if Dao[i] then
             begin        //4
       // X
             dXv := XUsko(i) * dt;    // + velo
             Vn[i] := Co*Vn[i] + dXv;    // New x velo
             dX := Vn[i] * dt;        // + koord
              Xn[i] := Xn[i] + dX;     // New koordinat

       // Y
              dYv := YUsko(i) * dt;    // + velo
              Un[i] := Co*Un[i] + dYv;    // New x velo
              dY := Un[i] * dt;        // + koord
              Yn[i] := Yn[i] + dY;     // New koordinat

       // Z
              dZv := ZUsko(i) * dt;    // + velo
              Wn[i] := Co*Wn[i] + dZv;    // New x velo
              dZ := Wn[i] * dt;        // + koord
              Zn[i] := Zn[i] + dZ;     // New koordinat
              end;       //4
             for i:=(MaxTaons-19) to MaxTaons do
             if Dao[i] then
             begin        //4
       // X
             dXv := XUsko(i) * dt;    // + velo
             Vn[i] := Co*Vn[i] + dXv;    // New x velo
             dX := Vn[i] * dt;        // + koord
              Xn[i] := Xn[i] + dX;     // New koordinat

       // Y
              dYv := YUsko(i) * dt;    // + velo
              Un[i] := Co*Un[i] + dYv;    // New x velo
              dY := Un[i] * dt;        // + koord
              Yn[i] := Yn[i] + dY;     // New koordinat

       // Z
              dZv := ZUsko(i) * dt;    // + velo
              Wn[i] := Co*Wn[i] + dZv;    // New x velo
              dZ := Wn[i] * dt;        // + koord
              Zn[i] := Zn[i] + dZ;     // New koordinat
              end;       //4


   // The new value send to Xo and Vo
             for i:=1 to (MaxTaons-30) do
              if Dao[i] then
              begin           //4
              Xo[i]:=Xn[i]; Vo[i]:=Vn[i];
             Yo[i]:=Yn[i]; Uo[i]:=Un[i];
              Zo[i]:=Zn[i]; Wo[i]:=Wn[i];
              x[i]:=Xn[i];
              y[i]:=Yn[i];
              z[i]:=Zn[i];
              end;            //4
             for i:=(MaxTaons-19) to MaxTaons do
              if Dao[i] then
              begin           //4
              Xo[i]:=Xn[i]; Vo[i]:=Vn[i];
             Yo[i]:=Yn[i]; Uo[i]:=Un[i];
              Zo[i]:=Zn[i]; Wo[i]:=Wn[i];
              x[i]:=Xn[i];
              y[i]:=Yn[i];
              z[i]:=Zn[i];
              end;            //4
   // Calculation of new value of koord and velo.
             for i:= MaxTaons-29 to MaxTaons-25 do
             if Dao[i] then
             begin        //4
       // X
             dXv := XUsko(i) * dt;    // + velo
             Vn[i] := Co*Vn[i] + dXv;    // New x velo
             dX := Vn[i] * dt;        // + koord
              Xn[i] := Xn[i] + dX;     // New koordinat

              end;       //4


          // The new value send to Xo and Vo
             for i:= MaxTaons-29 to MaxTaons-25 do
              if Dao[i] then
              begin           //4
              Xo[i]:=Xn[i]; Vo[i]:=Vn[i];
              x[i]:=Xn[i];
              end;            //4
         //*********************************
         end         //3
     else
         begin       //3
   // Calculation of new value of koord and velo.
//             for i:=1 to MaxTaons do
//             if Dao[i] then
             begin        //4
     begin  //3a
      for i:=1 to MaxTaons do
     begin    //3b
       // X
       dXv := XUsko(i) * dt;    // + velo
       Vn[i] := Co*Vn[i] + dXv;    // New x velo
       dX := Vn[i] * dt;        // + koord
       Xn[i] := Xn[i] + dX;     // New koordinat

       // Y
       dYv := YUsko(i) * dt;    // + velo
       Un[i] := Co*Un[i] + dYv;    // New x velo
       dY := Un[i] * dt;        // + koord
       Yn[i] := Yn[i] + dY;     // New koordinat

       // Z
       dZv := ZUsko(i) * dt;    // + velo
       Wn[i] := Co*Wn[i] + dZv;    // New x velo
       dZ := Wn[i] * dt;        // + koord
       Zn[i] := Zn[i] + dZ;     // New koordinat
     end;    //3b
     end;   //3a


   // The new value send to Xo and Vo

     begin  //3a
      for i:=1 to MaxTaons do
      begin  //3b
       Xo[i]:=Xn[i]; Vo[i]:=Vn[i];
       Yo[i]:=Yn[i]; Uo[i]:=Un[i];
       Zo[i]:=Zn[i]; Wo[i]:=Wn[i];
       x[i]:=Xn[i];
       y[i]:=Yn[i];
       z[i]:=Zn[i];
      end;   //3b
     end;   //3a
              end;            //4
         end;          //3

//**************************
//***************Stay1 Start
      if MainForm.Stay1.Checked then
      begin
      for i:=1 to (MaxTaons-99) do
      if (Zn[i]<=0.5) and (Zn[i]>0)  then
      begin     //1
      Wn[i]:=30*cos(Z[i]-5)
      end;    //1
      if (Zn[i]>=-0.5) and (Zn[i]<0) then
      begin     //1
      Wn[i]:=-30*cos(Z[i]-5)
      end;    //1
      end;
//***************Stay1 Finish
//***************Stay2 Start
      if MainForm.Stay2.Checked then
      begin
      for i:=1 to (MaxTaons-98) do
      if (Zn[i]<=0.5) and (Zn[i]>0)  then
      begin     //1
      Wn[i]:=30*cos(Z[i]-5)
      end;    //1
      if (Zn[i]>=-0.5) and (Zn[i]<0) then
      begin     //1
      Wn[i]:=-30*cos(Z[i]-5)
      end;    //1
      end;
//***************Stay2 Finish
//***************Stay3 Start
      if MainForm.Stay3.Checked then
      begin
      for i:=1 to (MaxTaons-97) do
      if (Zn[i]<=0.5) and (Zn[i]>0)  then
      begin     //1
      Wn[i]:=30*cos(Z[i]-5)
      end;    //1
      if (Zn[i]>=-0.5) and (Zn[i]<0) then
      begin     //1
      Wn[i]:=-30*cos(Z[i]-5)
      end;    //1
      end;
//***************Stay3 Finish
//***************Stay4 Start
      if MainForm.Stay4.Checked then
      begin
      for i:=1 to (MaxTaons-99) do
      begin
      if (Zn[i]<=0.5) and (Zn[i]>0)  then
      begin     //1
      Wn[i]:=30*cos(Z[i]-2.5)
      end;    //1
      if (Zn[i]>=-0.5) and (Zn[i]<0) then
      begin     //1
      Wn[i]:=-30*cos(Z[i]-2.5)
      end;    //1
      end;
      for i:=2 to (MaxTaons-98) do
      begin
      if (Yn[i]<=0.5) and (Yn[i]>0)  then
      begin     //1
      Un[i]:=30*cos(Y[i]-2.5)
      end;    //1
      if (Yn[i]>=-0.5) and (Yn[i]<0) then
      begin     //1
      Un[i]:=-30*cos(Y[i]-2.5)
      end;    //1
      end;
      end;
//***************Stay4 Finish
//***************Stay5 Start
      if MainForm.Stay5.Checked then
      begin
      for i:=1 to (MaxTaons-99) do
      begin
      if (Zn[i]<=0.5) and (Zn[i]>0)  then
      begin     //1
      Wn[i]:=30*cos(Z[i]-2.5)
      end;    //1
      if (Zn[i]>=-0.5) and (Zn[i]<0) then
      begin     //1
      Wn[i]:=-30*cos(Z[i]-2.5)
      end;    //1
      end;
      for i:=2 to (MaxTaons-98) do
      begin
      if (Yn[i]<=0.5) and (Yn[i]>0)  then
      begin     //1
      Un[i]:=30*cos(Y[i]-2.5)
      end;    //1
      if (Yn[i]>=-0.5) and (Yn[i]<0) then
      begin     //1
      Un[i]:=-30*cos(Y[i]-2.5)
      end;    //1
      end;
      for i:=3 to (MaxTaons-97) do
      begin
      if (Xn[i]<=0.5) and (Xn[i]>0)  then
      begin     //1
      Vn[i]:=30*cos(X[i]-2.5)
      end;    //1
      if (Xn[i]>=-0.5) and (Xn[i]<0) then
      begin     //1
      Vn[i]:=-30*cos(X[i]-2.5)
      end;    //1
      end;
      end;
//***************Stay5 Finish

  Time:=Num;
   if ShowLabelTime then
      MainForm.LTime.Caption:=IntToStr(Time);

   DrawLine;
   if MainForm.ShowList.Checked then ShowTable;
   //
   Application.ProcessMessages;
until Stop;
end;//Game;

// End of graphical proc

procedure TMainForm.Exit1Click(Sender: TObject);
begin
Close
end;

procedure TMainForm.FormPaint(Sender: TObject);
begin
     u0:=Round(width/2);v0:=Round(Pan.Top/2);
     if Spiral
        then
            begin
            ShowSpiral;
            end
        else
            begin
            ThisName:=StartFile;
            DrawLine;
            ShowTable;
            end;
end;

procedure TMainForm.TimerTimer(Sender: TObject);
begin
if Spin then
     if Spiral
        then ShowSpiral
        else DrawLine;
end;

procedure TMainForm.FormMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
if Button = mbRight
   then
       begin
       RStartX:=X;
       RStartY:=Y;
       end
   else
       begin
       LStartX:=X;
       LStartY:=Y;
       end;
end;

procedure TMainForm.FormMouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
if Button = mbRight
   then
       begin
       if RStartX<X then k:=k-KoUgol*(X-RStartX);
       if RStartX>X then k:=k+KoUgol*(RStartX-X);
       if RStartY<Y then xl:=xl-KoRass*(Y-RStartY);
       if RStartY>Y then xl:=xl+KoRass*(RStartY-Y);
       end
   else
       begin
       if LStartX<X then l:=l-KoUgol*(X-LStartX);
       if LStartX>X then l:=l+KoUgol*(LStartX-X);
       if LStartY<Y then j:=j+KoUgol*(Y-LStartY);
       if LStartY>Y then j:=j-KoUgol*(LStartY-Y);
       end;
     if Spiral
        then ShowSpiral
        else
            begin
            if Button = mbRight
               then
                   begin
                   ks:=ks+k;
                   end
               else
                   begin
                   ls:=ls+l;
                   js:=js+j;
                   end;
            DrawLine;
            k:=0;l:=0;j:=0;
            end;
  if not ShowSpin.Checked then begin k:=0;l:=0;j:=0 end;
end;

procedure TMainForm.ShowSpinClick(Sender: TObject);
begin
if ShowSpin.Checked
   then
       begin
       Spin:=false;
       ShowSpin.Checked:=false;
       end
   else
       begin
       Spin:=true;
       ShowSpin.Checked:=true;
       end
end;

procedure TMainForm.FormCreate(Sender: TObject);
var n:integer;
begin
     u0:=Round(width/2);v0:=Round(Pan.Top/2);
     xl:=120;
     j:=0;k:=0;l:=0;
     Spiral:=true;
     //Power:=false;
     MaxTaons:=MaxPunkt;
     TypeSpiral:=1;
     fsincos;
     AssignFile(FStartFile,'C:\Start.-as-');
     {$I-}
     Reset(FStartFile);
     {$I+}
     if IOResult=0
        then
            begin
            Read(FStartFile,StartFile);
            CloseFile(FStartFile);
            if StartFile=''
               then
                   begin
                   CreateFigure;
                   ThisName:='ThetraSpiral';
                   end
               else
                   begin
                   Spiral:=false;
                   Go.Enabled:=true;
                   ThisName:=StartFile;
                   FName.Text:=ThisName;
                   AssignFile(FTaons,ThisName);
                   {$I-}
                   Reset(FTaons);
                   {$I+}
                   if IOResult=0 then
                   begin
                   Read(FTaons, Taons);
                   CloseFile(FTaons);
                   // Write data of taons
                   dt:=Taons.dt;
                   A1:=Taons.A1;
                   B1:=Taons.B1;
                   C1:=Taons.C1;
                   D1:=Taons.D1;
                   F1:=Taons.F1;
                   G1:=Taons.G1;
                   A2:=Taons.A2;
                   B2:=Taons.B2;
                   C2:=Taons.C2;
                   D2:=Taons.D2;
                   F2:=Taons.F2;
                   G2:=Taons.G2;
                   A3:=Taons.A3;
                   B3:=Taons.B3;
                   C3:=Taons.C3;
                   D3:=Taons.D3;
                   F3:=Taons.F3;
                   G3:=Taons.G3;

                   for n:=1 to MaxTaons do
                       Dao[n]:=Taons.Dao[n];
                   for n:=1 to MaxTaons do
                       begin
                       Xo[n]:=Taons.Xo[n];
                       Yo[n]:=Taons.Yo[n];
                       Zo[n]:=Taons.Zo[n];
                       Vo[n]:=Taons.Vo[n];
                       Uo[n]:=Taons.Uo[n];
                       Wo[n]:=Taons.Wo[n];

                       x[n]:=Xo[n];Xn[n]:=Xo[n];
                       y[n]:=Yo[n];Yn[n]:=Yo[n];
                       z[n]:=Zo[n];Zn[n]:=Zo[n];
                       Vn[n]:=Vo[n];
                       Un[n]:=Uo[n];
                       Wn[n]:=Wo[n];
                       end;
                   // Commentary
                   n:=Length(ThisName);
                   Delete(ThisName,n-3,4);
                   AssignFile(FTaonsText, ThisName+'.txt');
                   {$I-} Reset(FTaonsText); {$I+}
                   if IOResult=0 then
                      begin
                          CloseFile(FTaonsText);
                          Comment.Lines.LoadFromFile(ThisName+'.txt');
                      end;
                   // End commentary
                   end
                   else
                       begin
                       CreateFigure;
                       FName.Text:='The easy square';
                       end
                   end
            end
        else
            begin
            Rewrite(FStartFile);
            CloseFile(FStartFile);
            CreateFigure;
            ThisName:='ThetraSpiral';
            end;
     KoBok:=5;
     KoRass:=3;
     KoUgol:=0.01;
     ShowTable;
     EditDT.Text:=FloatToStr(dt);
     EditA1.Text:=FloatToStr(A1);
     EditB1.Text:=FloatToStr(B1);
     EditC1.Text:=FloatToStr(C1);
     EditD1.Text:=FloatToStr(D1);
     EditF1.Text:=FloatToStr(F1);
     EditG1.Text:=FloatToStr(G1);
     EditA2.Text:=FloatToStr(A2);
     EditB2.Text:=FloatToStr(B2);
     EditC2.Text:=FloatToStr(C2);
     EditD2.Text:=FloatToStr(D2);
     EditF2.Text:=FloatToStr(F2);
     EditG2.Text:=FloatToStr(G2);
     EditA3.Text:=FloatToStr(A3);
     EditB3.Text:=FloatToStr(B3);
     EditC3.Text:=FloatToStr(C3);
     EditD3.Text:=FloatToStr(D3);
     EditF3.Text:=FloatToStr(F3);
     EditG3.Text:=FloatToStr(G3);
     Stop:=true;
     dt:=0.001;     // FalseTime
(*     A1:=1;
     B1:=2.718;
     C1:=5;
     D1:=10;
     F1:=20;
     G1:=30;
     A2:=1;
     B2:=2.718;
     C2:=5;
     D2:=10;
     F2:=20;
     G2:=30;
     A3:=1;
     B3:=2.718;
     C3:=5;
     D3:=10;
     F3:=20;
     G3:=30;
*)
end;

procedure TMainForm.FormResize(Sender: TObject);
var r:integer;
begin
     u0:=Round(width/2);v0:=Round(Pan.Top/2);
     r:=Panel1.Left-5;
     FName.Width:=r+3;
     Comment.Height:=PageControl.Height-29;
     Comment.Width:=r+3;
     PageControl.Width:=r;
     DaonsTable.Width:=r-2;
     DaonsTable.DefaultColWidth:=(r-30) div 6;
     if Spiral
        then ShowSpiral
        else DrawLine;
end;

procedure TMainForm.DaoTeta1Click(Sender: TObject);
begin
     j:=j+KoUgol;
     if Spiral
        then ShowSpiral
        else
            begin
            js:=js+j;
            DrawLine;
            end;
     j:=0;
end;

procedure TMainForm.DaoTetaClick(Sender: TObject);
begin
     j:=j-KoUgol;
     if Spiral
        then ShowSpiral
        else
            begin
            js:=js+j;
            DrawLine;
            end;
     j:=0;
end;

procedure TMainForm.DaoPsiClick(Sender: TObject);
begin
     k:=k-KoUgol;
     if Spiral
        then ShowSpiral
        else
            begin
            ks:=ks+k;
            DrawLine;
            end;
     k:=0;
end;

procedure TMainForm.DaoPsi1Click(Sender: TObject);
begin
     k:=k+KoUgol;
     if Spiral
        then ShowSpiral
        else
            begin
            ks:=ks+k;
            DrawLine;
            end;
     k:=0;
end;

procedure TMainForm.DaoStopClick(Sender: TObject);
begin
     k:=0;j:=0;l:=0;
     if Spiral
        then ShowSpiral
        else DrawLine;
end;

procedure TMainForm.DaoPhi1Click(Sender: TObject);
begin
     l:=l-KoUgol;
     if Spiral
        then ShowSpiral
        else
            begin
            ls:=ls+l;
            DrawLine;
            end;
     l:=0;
end;

procedure TMainForm.DaoPhiClick(Sender: TObject);
begin
     l:=l+KoUgol;
     if Spiral
        then ShowSpiral
        else
            begin
            ls:=ls+l;
            DrawLine;
            end;
     l:=0;
end;

procedure TMainForm.DaoBackClick(Sender: TObject);
begin
     // Íà îòäàëåíèå îáúåêòà
     if xl < 9*KoRass
        then xl:=xl/KoRass
        else xl:=xl-KoRass*3;
     if Spiral
        then ShowSpiral
        else DrawLine;
end;

procedure TMainForm.DaoForvardClick(Sender: TObject);
begin
     // Íà ïðèáëèæåíèå îáúåêòà
     xl:=xl+KoRass*3;
     if Spiral
        then ShowSpiral
        else DrawLine;
end;

procedure TMainForm.TrackBarChange(Sender: TObject);
begin
case TrackBar.Position of
     0:KoUgol:=0.0005;
     1:KoUgol:=0.001;
     2:KoUgol:=0.002;
     3:KoUgol:=0.003;
     4:KoUgol:=0.005;
     5:KoUgol:=0.01;
     6:KoUgol:=0.05;
     7:KoUgol:=0.1;
     8:KoUgol:=0.5;
     9:KoUgol:=1;
     10:KoUgol:=2;
     end;
case TrackBar.Position of
     0:KoRass:=0.5;
     1:KoRass:=1;
     2:KoRass:=2;
     3:KoRass:=3;
     4:KoRass:=5;
     5:KoRass:=7;
     6:KoRass:=10;
     7:KoRass:=15;
     8:KoRass:=20;
     9:KoRass:=30;
     10:KoRass:=50;
     end;
end;

procedure TMainForm.ShowNumbersOfPointsClick(Sender: TObject);
begin
if ShowNumbersOfPoints.Checked
   then
       begin
       ShowNumbersOfPunkts:=false;
       ShowNumbersOfPoints.Checked:=false;
       end
   else
       begin
       ShowNumbersOfPunkts:=true;
       ShowNumbersOfPoints.Checked:=true;
       end;
if Spiral
   then ShowSpiral
   else DrawLine;
end;

procedure TMainForm.Spiral1Click(Sender: TObject);
begin
     Spiral:=true;
     CreateFigure;
     Go.Enabled:=false;
     Null00.Enabled:=false;
     ShowSpiral;
end;

procedure TMainForm.Daons1Click(Sender: TObject);
var n:integer;
begin
     Spiral:=false;
     Go.Enabled:=true;
     Null00.Enabled:=true;
     {$I-}
     Reset(FStartFile);
     {$I+}
     if IOResult=0
        then
            begin
            Read(FStartFile,StartFile);
            CloseFile(FStartFile);
            if StartFile=''
               then
                   begin
                   CreateFigure;
                   ThisName:='This is a stabil structur of taons';
                   CreateFigure;
                   ShowTable;
                   FName.Text:=ThisName;
                   DrawLine;
                   end
               else
                   begin
                   Spiral:=false;
                   ThisName:=StartFile;
                   FName.Text:=ThisName;
                   AssignFile(FTaons,ThisName);
                   {$I-}
                   Reset(FTaons);
                   {$I+}
                   if IOResult=0 then
                   begin
                   Read(FTaons, Taons);
                   CloseFile(FTaons);
                   // Write data of taons
                   dt:=Taons.dt;
                   A1:=Taons.A1;
                   B1:=Taons.B1;
                   C1:=Taons.C1;
                   D1:=Taons.D1;
                   F1:=Taons.F1;
                   G1:=Taons.G1;
                   A2:=Taons.A2;
                   B2:=Taons.B2;
                   C2:=Taons.C2;
                   D2:=Taons.D2;
                   F2:=Taons.F2;
                   G2:=Taons.G2;
                   A3:=Taons.A3;
                   B3:=Taons.B3;
                   C3:=Taons.C3;
                   D3:=Taons.D3;
                   F3:=Taons.F3;
                   G3:=Taons.G3;
                   for n:=1 to MaxTaons do
                       Dao[n]:=Taons.Dao[n];
                   for n:=1 to MaxTaons do
                       begin
                       Xo[n]:=Taons.Xo[n];
                       Yo[n]:=Taons.Yo[n];
                       Zo[n]:=Taons.Zo[n];
                       Vo[n]:=Taons.Vo[n];
                       Uo[n]:=Taons.Uo[n];
                       Wo[n]:=Taons.Wo[n];

                       x[n]:=Xo[n];Xn[n]:=Xo[n];
                       y[n]:=Yo[n];Yn[n]:=Yo[n];
                       z[n]:=Zo[n];Zn[n]:=Zo[n];
                       Vn[n]:=Vo[n];
                       Un[n]:=Uo[n];
                       Wn[n]:=Wo[n];
                       end;
                   DrawLine;
                   ShowTable;
                   end
                   else
                       begin
                       CreateFigure;
                       end
                   end
            end
        else
            MessageDlg('The start File not found.', mtInformation, [mbOk], 0);
end;

procedure TMainForm.Left1Click(Sender: TObject);
begin
     xt:=xt-KoBok;
     if Spiral
        then ShowSpiral
        else DrawLine;
end;

procedure TMainForm.Right1Click(Sender: TObject);
begin
     xt:=xt+KoBok;
     if Spiral
        then ShowSpiral
        else DrawLine;
end;

procedure TMainForm.Up1Click(Sender: TObject);
begin
     zt:=zt-KoBok;
     if Spiral
        then ShowSpiral
        else DrawLine;
end;

procedure TMainForm.Down1Click(Sender: TObject);
begin
     zt:=zt+KoBok;
     if Spiral
        then ShowSpiral
        else DrawLine;
end;

procedure TMainForm.GoClick(Sender: TObject);
begin
if not Stop
   then
       begin
       Go.Kind:=bkOK;
       Go.Caption:='Go';
       ShapeRed.Brush.Color:=clMaroon;
       ShapeLime.Brush.Color:=clLime;
       Stop:=true;
       Images.Enabled:=true;
       Null00.Enabled:=true;
       end
   else
       begin
       Go.Kind:=bkCancel;
       Go.Caption:='Stop';
       ShapeRed.Brush.Color:=clRed;
       ShapeLime.Brush.Color:=clGreen;
       Stop:=false;
       Images.Enabled:=false;
       Null00.Enabled:=false;
       Null00.Caption:='0';
       Null00.Font.Color:=clMaroon;
       Game(Time);
       end;
end;

procedure TMainForm.DaonsTableDblClick(Sender: TObject);
begin
VeloCity:=not VeloCity; ShowTable;
end;

procedure TMainForm.New1Click(Sender: TObject);
begin
if EditDlg.ShowModal = mrOK then
   begin
   Spiral:=false;
   Go.Enabled:=true;
   Null00.Enabled:=true;
   FName.Text:=ThisName;
   Time:=0; LTime.Caption:='0';
   // Show result
   DrawLine;
   ShowTable;
   EditDT.Text:=FloatToStr(dt);
   EditA1.Text:=FloatToStr(A1);
   EditB1.Text:=FloatToStr(B1);
   EditC1.Text:=FloatToStr(C1);
   EditD1.Text:=FloatToStr(D1);
   EditF1.Text:=FloatToStr(F1);
   EditG1.Text:=FloatToStr(G1);
   EditA2.Text:=FloatToStr(A2);
   EditB2.Text:=FloatToStr(B2);
   EditC2.Text:=FloatToStr(C2);
   EditD2.Text:=FloatToStr(D2);
   EditF2.Text:=FloatToStr(F2);
   EditG2.Text:=FloatToStr(G2);
   EditA3.Text:=FloatToStr(A3);
   EditB3.Text:=FloatToStr(B3);
   EditC3.Text:=FloatToStr(C3);
   EditD3.Text:=FloatToStr(D3);
   EditF3.Text:=FloatToStr(F3);
   EditG3.Text:=FloatToStr(G3);
   //
   end;
end;

procedure TMainForm.Open1Click(Sender: TObject);
var n:integer;
begin
if OpenDialog.Execute then
   begin
   Spiral:=false;
   Go.Enabled:=true;
   Null00.Enabled:=true;
   ThisName:=OpenDialog.FileName;
   FName.Text:=ThisName;
   AssignFile(FTaons,OpenDialog.FileName);
   Reset(FTaons);
   Read(FTaons, Taons);
   CloseFile(FTaons);
   StartFile:=ThisName;
   Rewrite(FStartFile);
   Write(FStartFile, StartFile);
   CloseFile(FStartFile);
   // Write data of taons
   dt:=Taons.dt;
   A1:=Taons.A1;
   B1:=Taons.B1;
   C1:=Taons.C1;
   D1:=Taons.D1;
   F1:=Taons.F1;
   G1:=Taons.G1;
   A2:=Taons.A2;
   B2:=Taons.B2;
   C2:=Taons.C2;
   D2:=Taons.D2;
   F2:=Taons.F2;
   G2:=Taons.G2;
   A3:=Taons.A3;
   B3:=Taons.B3;
   C3:=Taons.C3;
   D3:=Taons.D3;
   F3:=Taons.F3;
   G3:=Taons.G3;

   for n:=1 to MaxTaons do
       Dao[n]:=Taons.Dao[n];
   for n:=1 to MaxTaons do
       begin
       Xo[n]:=Taons.Xo[n];
       Yo[n]:=Taons.Yo[n];
       Zo[n]:=Taons.Zo[n];
       Vo[n]:=Taons.Vo[n];
       Uo[n]:=Taons.Uo[n];
       Wo[n]:=Taons.Wo[n];

       x[n]:=Xo[n];Xn[n]:=Xo[n];
       y[n]:=Yo[n];Yn[n]:=Yo[n];
       z[n]:=Zo[n];Zn[n]:=Zo[n];
       Vn[n]:=Vo[n];
       Un[n]:=Uo[n];
       Wn[n]:=Wo[n];
       end;
   // Show result
   Time:=0; LTime.Caption:='0';
   DrawLine;
   ShowTable;
   EditDT.Text:=FloatToStr(dt);
   EditA1.Text:=FloatToStr(A1);
   EditB1.Text:=FloatToStr(B1);
   EditC1.Text:=FloatToStr(C1);
   EditD1.Text:=FloatToStr(D1);
   EditF1.Text:=FloatToStr(F1);
   EditG1.Text:=FloatToStr(G1);
   EditA2.Text:=FloatToStr(A2);
   EditB2.Text:=FloatToStr(B2);
   EditC2.Text:=FloatToStr(C2);
   EditD2.Text:=FloatToStr(D2);
   EditF2.Text:=FloatToStr(F2);
   EditG2.Text:=FloatToStr(G2);
   EditA3.Text:=FloatToStr(A3);
   EditB3.Text:=FloatToStr(B3);
   EditC3.Text:=FloatToStr(C3);
   EditD3.Text:=FloatToStr(D3);
   EditF3.Text:=FloatToStr(F3);
   EditG3.Text:=FloatToStr(G3);
   //
   // Commentary
   n:=Length(ThisName);
   Delete(ThisName,n-3,4);
   AssignFile(FTaonsText, ThisName+'.txt');
   {$I-}
   Reset(FTaonsText);
   {$I+}
   if IOResult=0 then
      begin
      CloseFile(FTaonsText);
      Comment.Lines.LoadFromFile(ThisName+'.txt');
      end;
   // End commentary
   end;
end;

procedure TMainForm.Save1Click(Sender: TObject);
begin
if not Spiral then
   begin
   SaveDataOfTaons;
   AssignFile(FTaons, ThisName);
   Rewrite(FTaons);
   Write(FTaons, Taons);
   CloseFile(FTaons);
   end;
end;

procedure TMainForm.Saveas1Click(Sender: TObject);
begin
if not Spiral then
if SaveDialog.Execute then
   begin
   ThisName:=SaveDialog.FileName;
   FName.Text:=ThisName;
   SaveDataOfTaons;
   AssignFile(FTaons,SaveDialog.FileName);
   Rewrite(FTaons);
   Write(FTaons, Taons);
   CloseFile(FTaons);
   StartFile:=ThisName;
   {$I-}
   Rewrite(FStartFile);
   {$I+}
   Write(FStartFile,StartFile);
   CloseFile(FStartFile);
   end;
end;

procedure TMainForm.MoveToCenterClick(Sender: TObject);
begin
xl:=120;
xt:=0;zt:=0;
if Spiral
   then ShowSpiral
   else DrawLine;
end;

procedure TMainForm.CommentChange(Sender: TObject);
begin
EditComm:=true;
end;

procedure TMainForm.CommentExit(Sender: TObject);
var n:integer;
begin
if EditComm then
   begin
   EditComm:=false;
   if MessageDlg('The text was changed. Save now?',
      mtConfirmation, [mbYes, mbNo], 0) = mrYes then
      begin
      n:=Length(ThisName);
      Delete(ThisName,n-3,4);
      AssignFile(FTaonsText, ThisName+'.txt');
      Rewrite(FTaonsText);
      //Write(FTaonsText, '');
      CloseFile(FTaonsText);
      Comment.Lines.SaveToFile(ThisName+'.txt');
      //Comment.Lines.LoadFromFile(ThisName);
      end
   end
end;

procedure TMainForm.About1Click(Sender: TObject);
begin
AboutBox.ShowModal;
end;

procedure TMainForm.Help1Click(Sender: TObject);
begin

  Application.HelpFile := 'HlpArtUk.hlp';
  Application.HelpCommand(HELP_CONTENTS, 0);

end;
//*****************
procedure TMainForm.RusHelpClick(Sender: TObject);
  begin
     Application.HelpFile := 'HlpArtRu.hlp';
     Application.HelpCommand(HELP_CONTENTS, 0);
  end;
procedure TMainForm.PolHelpClick(Sender: TObject);
  begin
       Application.HelpFile := 'HlpArtPl.hlp';
       Application.HelpCommand(HELP_CONTENTS, 0);
  end;

procedure TMainForm.EditDTKeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9']) then
   if not (Key in ['-',',','.',#08]) then Key := #27
end;

procedure TMainForm.EditA1KeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9']) then
   if not (Key in ['-',',','.',#08]) then Key := #27
end;

procedure TMainForm.EditB1KeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9']) then
   if not (Key in ['-',',','.',#08]) then Key := #27
end;

procedure TMainForm.EditC1KeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9']) then
   if not (Key in ['-',',','.',#08]) then Key := #27
end;

procedure TMainForm.EditD1KeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9']) then
   if not (Key in ['-',',','.',#08]) then Key := #27
end;

procedure TMainForm.EditF1KeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9']) then
   if not (Key in ['-',',','.',#08]) then Key := #27
end;

procedure TMainForm.EditG1KeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9']) then
   if not (Key in ['-',',','.',#08]) then Key := #27
end;

procedure TMainForm.EditA2KeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9']) then
   if not (Key in ['-',',','.',#08]) then Key := #27
end;

procedure TMainForm.EditB2KeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9']) then
   if not (Key in ['-',',','.',#08]) then Key := #27
end;

procedure TMainForm.EditC2KeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9']) then
   if not (Key in ['-',',','.',#08]) then Key := #27
end;

procedure TMainForm.EditD2KeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9']) then
   if not (Key in ['-',',','.',#08]) then Key := #27
end;

procedure TMainForm.EditF2KeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9']) then
   if not (Key in ['-',',','.',#08]) then Key := #27
end;

procedure TMainForm.EditG2KeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9']) then
   if not (Key in ['-',',','.',#08]) then Key := #27
end;

procedure TMainForm.EditA3KeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9']) then
   if not (Key in ['-',',','.',#08]) then Key := #27
end;

procedure TMainForm.EditB3KeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9']) then
   if not (Key in ['-',',','.',#08]) then Key := #27
end;

procedure TMainForm.EditC3KeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9']) then
   if not (Key in ['-',',','.',#08]) then Key := #27
end;

procedure TMainForm.EditD3KeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9']) then
   if not (Key in ['-',',','.',#08]) then Key := #27
end;

procedure TMainForm.EditF3KeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9']) then
   if not (Key in ['-',',','.',#08]) then Key := #27
end;

procedure TMainForm.EditG3KeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9']) then
   if not (Key in ['-',',','.',#08]) then Key := #27
end;

procedure TMainForm.EditDTExit(Sender: TObject);
begin
dt:=StrToFloat(EditDT.Text);
end;

procedure TMainForm.EditA1Exit(Sender: TObject);
begin
A1:=StrToFloat(EditA1.Text);
end;

procedure TMainForm.EditB1Exit(Sender: TObject);
begin
B1:=StrToFloat(EditB1.Text);
end;

procedure TMainForm.EditC1Exit(Sender: TObject);
begin
C1:=StrToFloat(EditC1.Text);
end;

procedure TMainForm.EditD1Exit(Sender: TObject);
begin
D1:=StrToFloat(EditD1.Text);
end;

procedure TMainForm.EditF1Exit(Sender: TObject);
begin
F1:=StrToFloat(EditF1.Text);
end;

procedure TMainForm.EditG1Exit(Sender: TObject);
begin
G1:=StrToFloat(EditG1.Text);
end;

procedure TMainForm.EditA2Exit(Sender: TObject);
begin
A2:=StrToFloat(EditA2.Text);
end;

procedure TMainForm.EditB2Exit(Sender: TObject);
begin
B2:=StrToFloat(EditB2.Text);
end;

procedure TMainForm.EditC2Exit(Sender: TObject);
begin
C2:=StrToFloat(EditC2.Text);
end;

procedure TMainForm.EditD2Exit(Sender: TObject);
begin
D2:=StrToFloat(EditD2.Text);
end;

procedure TMainForm.EditF2Exit(Sender: TObject);
begin
F2:=StrToFloat(EditF2.Text);
end;

procedure TMainForm.EditG2Exit(Sender: TObject);
begin
G2:=StrToFloat(EditG2.Text);
end;

procedure TMainForm.EditA3Exit(Sender: TObject);
begin
A3:=StrToFloat(EditA3.Text);
end;

procedure TMainForm.EditB3Exit(Sender: TObject);
begin
B3:=StrToFloat(EditB3.Text);
end;

procedure TMainForm.EditC3Exit(Sender: TObject);
begin
C3:=StrToFloat(EditC3.Text);
end;

procedure TMainForm.EditD3Exit(Sender: TObject);
begin
D3:=StrToFloat(EditD3.Text);
end;

procedure TMainForm.EditF3Exit(Sender: TObject);
begin
F3:=StrToFloat(EditF3.Text);
end;

procedure TMainForm.EditG3Exit(Sender: TObject);
begin
G3:=StrToFloat(EditG3.Text);
end;

procedure TMainForm.Null00Click(Sender: TObject);
var i:integer;
begin
if not Spiral then
if Stop then
   begin
   for i:=1 to MaxTaons do
       begin
       Vo[i]:=0;Uo[i]:=0;Wo[i]:=0;
       Vn[i]:=0;Un[i]:=0;Wn[i]:=0;
       end;
   Null00.Caption:='Yes Null';
   Null00.Font.Color:=clMaroon;
   ShowTable;
   if SaveDialog.Execute then
      begin
      ThisName:=SaveDialog.FileName;
      FName.Text:=ThisName;
      SaveDataOfTaons;
      AssignFile(FTaons,SaveDialog.FileName);
      Rewrite(FTaons);
      Write(FTaons, Taons);
      CloseFile(FTaons);
      StartFile:=ThisName;
      {$I-}
      Rewrite(FStartFile);
      {$I+}
      Write(FStartFile,StartFile);
      CloseFile(FStartFile);
      end;
   end
end;

procedure TMainForm.LTimeDblClick(Sender: TObject);
begin
ShowLabelTime := not ShowLabelTime;
end;

end.
**********************************************
unit Edit;

interface

uses Windows, SysUtils, Classes, Graphics, Forms, Controls, StdCtrls,
  Buttons, ExtCtrls, Grids, Dialogs;

type
  TEditDlg = class(TForm)
    OKBtn: TButton;
    CancelBtn: TButton;
    Bevel1: TBevel;
    DaonsTable: TStringGrid;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    EditX: TEdit;
    Label6: TLabel;
    EditY: TEdit;
    Label7: TLabel;
    EditZ: TEdit;
    Label9: TLabel;
    Label8: TLabel;
    EditV: TEdit;
    Label10: TLabel;
    EditU: TEdit;
    Label11: TLabel;
    EditW: TEdit;
    Submit: TBitBtn;
    Label12: TLabel;
    NumberOfTaon: TLabel;
    Label15: TLabel;
    EditDT: TEdit;
    EditA1: TEdit;
    EditB1: TEdit;
    EditC1: TEdit;
    EditD1: TEdit;
    EditF1: TEdit;
    EditA2: TEdit;
    EditB2: TEdit;
    EditC2: TEdit;
    EditD2: TEdit;
    EditF2: TEdit;
    EditA3: TEdit;
    EditB3: TEdit;
    EditC3: TEdit;
    EditD3: TEdit;
    EditF3: TEdit;
    Label16: TLabel;
    DaoTrue: TCheckBox;
    Label13: TLabel;
    SaveDialog: TSaveDialog;
    Saveas: TButton;
    EditFileName: TEdit;
    Label24: TLabel;
    Label25: TLabel;
    Label14: TLabel;
    Label18: TLabel;
    Label19: TLabel;
    Label21: TLabel;
    Label20: TLabel;
    Label22: TLabel;
    Edit1: TEdit;
    Edit2: TEdit;
    Label17: TLabel;
    Label23: TLabel;
    Label26: TLabel;
    Label27: TLabel;
    Label28: TLabel;
    Label30: TLabel;
    Label31: TLabel;
    Label32: TLabel;
    Label34: TLabel;
    Label35: TLabel;
    Label37: TLabel;
    EditCal1Part1: TEdit;
    EditCal1Part2: TEdit;
    EditCal2Part1: TEdit;
    EditCal2Part2: TEdit;
    EditCal3Part1: TEdit;
    EditCal3Part2: TEdit;
    EditCal4Part1: TEdit;
    EditCal4Part2: TEdit;
    EditResult1: TEdit;
    EditResult2: TEdit;
    EditResult3: TEdit;
    EditResult4: TEdit;   
    Calculate1: TButton;
    Reset1: TButton;
    Calculate2: TButton;
    Reset2: TButton;
    Calculate3: TButton;
    Reset3: TButton;
    Label29: TLabel;
    Label33: TLabel;
    Label36: TLabel;
    Label38: TLabel;
    Label39: TLabel;
    Label40: TLabel;
    Label41: TLabel;
    Label42: TLabel;
    Edit8: TEdit;
    Calculate4: TButton;
    Reset4: TButton;
    EditG1: TEdit;
    EditG2: TEdit;
    EditG3: TEdit;
    Label43: TLabel;
    Label44: TLabel;
    Label45: TLabel;
    Edit3: TEdit;
    Label46: TLabel;
    Label47: TLabel;
    Label48: TLabel;
    Label49: TLabel;
    Del: TCheckBox;
    EditCal5Part1: TEdit;
    EditCal5Part2: TEdit;
    EditCal5Part3: TEdit;
    EditResultX4: TEdit;
    EditResultY4: TEdit;
    EditResultZ4: TEdit;
    Calculate5: TButton;
    Reset5: TButton;
    DataToCel: TButton;
    ToCel: TEdit;
    procedure DaonsTableDblClick(Sender: TObject);
    procedure EditDTKeyPress(Sender: TObject; var Key: Char);
    procedure EditA1KeyPress(Sender: TObject; var Key: Char);
    procedure EditB1KeyPress(Sender: TObject; var Key: Char);
    procedure EditC1KeyPress(Sender: TObject; var Key: Char);
    procedure EditD1KeyPress(Sender: TObject; var Key: Char);
    procedure EditF1KeyPress(Sender: TObject; var Key: Char);
    procedure EditG1KeyPress(Sender: TObject; var Key: Char);
    procedure EditA2KeyPress(Sender: TObject; var Key: Char);
    procedure EditB2KeyPress(Sender: TObject; var Key: Char);
    procedure EditC2KeyPress(Sender: TObject; var Key: Char);
    procedure EditD2KeyPress(Sender: TObject; var Key: Char);
    procedure EditF2KeyPress(Sender: TObject; var Key: Char);
    procedure EditG2KeyPress(Sender: TObject; var Key: Char);
    procedure EditA3KeyPress(Sender: TObject; var Key: Char);
    procedure EditB3KeyPress(Sender: TObject; var Key: Char);
    procedure EditC3KeyPress(Sender: TObject; var Key: Char);
    procedure EditD3KeyPress(Sender: TObject; var Key: Char);
    procedure EditF3KeyPress(Sender: TObject; var Key: Char);
    procedure EditG3KeyPress(Sender: TObject; var Key: Char);
    procedure EditUKeyPress(Sender: TObject; var Key: Char);
    procedure EditVKeyPress(Sender: TObject; var Key: Char);
    procedure EditWKeyPress(Sender: TObject; var Key: Char);
    procedure EditXKeyPress(Sender: TObject; var Key: Char);
    procedure EditYKeyPress(Sender: TObject; var Key: Char);
    procedure EditZKeyPress(Sender: TObject; var Key: Char);

    procedure EditCal1Part1KeyPress(Sender: TObject; var Key: Char);
    procedure EditCal1Part2KeyPress(Sender: TObject; var Key: Char);
    procedure EditCal2Part1KeyPress(Sender: TObject; var Key: Char);
    procedure EditCal2Part2KeyPress(Sender: TObject; var Key: Char);
    procedure EditCal3Part1KeyPress(Sender: TObject; var Key: Char);
    procedure EditCal3Part2KeyPress(Sender: TObject; var Key: Char);
    procedure EditCal4Part1KeyPress(Sender: TObject; var Key: Char);
    procedure EditCal4Part2KeyPress(Sender: TObject; var Key: Char);
    procedure EditCal5Part1KeyPress(Sender: TObject; var Key: Char);
    procedure EditCal5Part2KeyPress(Sender: TObject; var Key: Char);
    procedure EditCal5Part3KeyPress(Sender: TObject; var Key: Char);
//    procedure EditToCelKeyPress(Sender: TObject; var Key: Char);

    procedure DaonsTableSelectCell(Sender: TObject; ACol, ARow: Integer;
      var CanSelect: Boolean);
    procedure FormPaint(Sender: TObject);
    procedure SubmitClick(Sender: TObject);
    procedure OKBtnClick(Sender: TObject);

    procedure Calculate1Click(Sender: TObject);
    procedure Reset1Click(Sender: TObject);
    procedure Calculate2Click(Sender: TObject);
    procedure Reset2Click(Sender: TObject);
    procedure Calculate3Click(Sender: TObject);
    procedure Reset3Click(Sender: TObject);
    procedure Calculate4Click(Sender: TObject);
    procedure Reset4Click(Sender: TObject);
    procedure Calculate5Click(Sender: TObject);
    procedure Reset5Click(Sender: TObject);

    procedure SaveasClick(Sender: TObject);
    procedure DaonsTableClick(Sender: TObject);
//    procedure DataToCelClick(Sender: TObject);
//    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  EditDlg: TEditDlg;

implementation

uses Global, Main;

{$R *.DFM}

var
   VeloCity
                    :boolean;

procedure ShowTable1;
var ii,jj:integer;
begin
with EditDlg do
     with DaonsTable do
     if not VeloCity
     then
     begin
            begin
                //Natschalo koda Taoscope
                if MainForm.Taoscope.Checked
                then
                Cells[0,0]:='Taons';
                //Konets koda Taoscope i natschalo koda Gravoscope
                if MainForm.Gravoscope.Checked
                then
                Cells[0,0]:='Gravons';
                //Konets koda Gravoscope
           end;

     Cells[1,0]:='X';Cells[2,0]:='Y';Cells[3,0]:='Z';
     for jj:=1 to MaxTaons do
         Cells[0,jj]:=IntToStr(jj);

     for ii := 1 to MaxTaons do
     for jj:= 1 to RowCount do
     if Dao[ii]
        then
        case jj of

         1:Cells[jj,ii] := FloatToStr(Xo[ii]);
         2:Cells[jj,ii] := FloatToStr(Yo[ii]);
         3:Cells[jj,ii] := FloatToStr(Zo[ii]);
        end
        else
            Cells[jj,ii] := '';
     end
     else
     begin
     Cells[0,0]:='Velo';
     Cells[1,0]:='u(x)';Cells[2,0]:='u(y)';Cells[3,0]:='u(z)';
     for jj:=1 to MaxTaons do
         Cells[0,jj]:=IntToStr(jj);

     for ii := 1 to MaxTaons do
     for jj:= 1 to RowCount do
     if Dao[ii]
        then
        case jj of
         1:Cells[jj,ii] := FloatToStr(Vo[ii]);
         2:Cells[jj,ii] := FloatToStr(Uo[ii]);
         3:Cells[jj,ii] := FloatToStr(Wo[ii]);
        end
        else
            Cells[jj,ii] := '';
     end;
end;
// End special procedures

procedure TEditDlg.DaonsTableDblClick(Sender: TObject);
begin
VeloCity:=not VeloCity; ShowTable1;
end;

procedure TEditDlg.EditDTKeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9']) then
   if not (Key in ['-',',','.',#08]) then Key := #27
end;

procedure TEditDlg.EditCal1Part1KeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9']) then
   if not (Key in ['-',',','.',#08]) then Key := #27
end;

procedure TEditDlg.EditCal1Part2KeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9']) then
   if not (Key in ['-',',','.',#08]) then Key := #27
end;

procedure TEditDlg.EditCal2Part1KeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9']) then
   if not (Key in ['-',',','.',#08]) then Key := #27
end;

procedure TEditDlg.EditCal2Part2KeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9']) then
   if not (Key in ['-',',','.',#08]) then Key := #27
end;

procedure TEditDlg.EditCal3Part1KeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9']) then
   if not (Key in ['-',',','.',#08]) then Key := #27
end;

procedure TEditDlg.EditCal3Part2KeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9']) then
   if not (Key in ['-',',','.',#08]) then Key := #27
end;

procedure TEditDlg.EditCal4Part1KeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9']) then
   if not (Key in ['-',',','.',#08]) then Key := #27
end;

procedure TEditDlg.EditCal4Part2KeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9']) then
   if not (Key in ['-',',','.',#08]) then Key := #27
end;

procedure TEditDlg.EditCal5Part1KeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9']) then
   if not (Key in ['-',',','.',#08]) then Key := #27
end;

procedure TEditDlg.EditCal5Part2KeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9']) then
   if not (Key in ['-',',','.',#08]) then Key := #27
end;

procedure TEditDlg.EditCal5Part3KeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9']) then
   if not (Key in ['-',',','.',#08]) then Key := #27
end;

(*procedure TEditDlg.EditCal5ZnakKeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9']) then
   if not (Key in ['-',',','.',#08]) then Key := #27
end;*)

procedure TEditDlg.EditA1KeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9']) then
   if not (Key in ['-',',','.',#08]) then Key := #27
end;

procedure TEditDlg.EditB1KeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9']) then
   if not (Key in ['-',',','.',#08]) then Key := #27
end;

procedure TEditDlg.EditC1KeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9']) then
   if not (Key in ['-',',','.',#08]) then Key := #27
end;

procedure TEditDlg.EditD1KeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9']) then
   if not (Key in ['-',',','.',#08]) then Key := #27
end;

procedure TEditDlg.EditF1KeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9']) then
   if not (Key in ['-',',','.',#08]) then Key := #27
end;

procedure TEditDlg.EditG1KeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9']) then
   if not (Key in ['-',',','.',#08]) then Key := #27
end;

procedure TEditDlg.EditA2KeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9']) then
   if not (Key in ['-',',','.',#08]) then Key := #27
end;

procedure TEditDlg.EditB2KeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9']) then
   if not (Key in ['-',',','.',#08]) then Key := #27
end;

procedure TEditDlg.EditC2KeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9']) then
   if not (Key in ['-',',','.',#08]) then Key := #27
end;

procedure TEditDlg.EditD2KeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9']) then
   if not (Key in ['-',',','.',#08]) then Key := #27
end;

procedure TEditDlg.EditF2KeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9']) then
   if not (Key in ['-',',','.',#08]) then Key := #27
end;

procedure TEditDlg.EditG2KeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9']) then
   if not (Key in ['-',',','.',#08]) then Key := #27
end;

procedure TEditDlg.EditA3KeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9']) then
   if not (Key in ['-',',','.',#08]) then Key := #27
end;

procedure TEditDlg.EditB3KeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9']) then
   if not (Key in ['-',',','.',#08]) then Key := #27
end;

procedure TEditDlg.EditC3KeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9']) then
   if not (Key in ['-',',','.',#08]) then Key := #27
end;

procedure TEditDlg.EditD3KeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9']) then
   if not (Key in ['-',',','.',#08]) then Key := #27
end;

procedure TEditDlg.EditF3KeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9']) then
   if not (Key in ['-',',','.',#08]) then Key := #27
end;

procedure TEditDlg.EditG3KeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9']) then
   if not (Key in ['-',',','.',#08]) then Key := #27
end;

procedure TEditDlg.EditUKeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9']) then
   if not (Key in ['-',',','.',#08]) then Key := #27
end;

procedure TEditDlg.EditVKeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9']) then
   if not (Key in ['-',',','.',#08]) then Key := #27
end;

procedure TEditDlg.EditWKeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9']) then
   if not (Key in ['-',',','.',#08]) then Key := #27
end;

procedure TEditDlg.EditXKeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9']) then
   if not (Key in ['-',',','.',#08]) then Key := #27
end;

procedure TEditDlg.EditYKeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9']) then
   if not (Key in ['-',',','.',#08]) then Key := #27
end;

procedure TEditDlg.EditZKeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9']) then
   if not (Key in ['-',',','.',#08]) then Key := #27
end;

//CALCULATION 1
procedure TEditDlg.Calculate1Click(Sender: TObject);
var  n1, n2   :integer;
X1, X2, Y1, Y2, Z1, Z2, D  :extended;

begin

   n1:=StrToInt(EditCal1Part1.Text);
   X1:=StrToFloat(DaonsTable.Cells[1,n1]);
   Y1:=StrToFloat(DaonsTable.Cells[2,n1]);
   Z1:=StrToFloat(DaonsTable.Cells[3,n1]);

   n2:=StrToInt(EditCal1Part2.Text);
   X2:=StrToFloat(DaonsTable.Cells[1,n2]);
   Y2:=StrToFloat(DaonsTable.Cells[2,n2]);
   Z2:=StrToFloat(DaonsTable.Cells[3,n2]);

   D:=Sqrt((Sqr(X2-X1))+(Sqr(Y2-Y1))+(Sqr(Z2-Z1)));
   EditResult1.Text:='0';
   EditResult1.Text:=FloatToStr(D);
end;

procedure TEditDlg.Reset1Click(Sender: TObject);
begin
EditCal1Part1.Text:='0'; EditCal1Part2.Text:='0'; EditResult1.Text:='0';
end;
//CALCULATION 2
procedure TEditDlg.Calculate2Click(Sender: TObject);
var  n1, n2   :integer;
X1, X2, Y1, Y2, Z1, Z2, D  :extended;

begin

   n1:=StrToInt(EditCal2Part1.Text);
   X1:=StrToFloat(DaonsTable.Cells[1,n1]);
   Y1:=StrToFloat(DaonsTable.Cells[2,n1]);
   Z1:=StrToFloat(DaonsTable.Cells[3,n1]);

   n2:=StrToInt(EditCal2Part2.Text);
   X2:=StrToFloat(DaonsTable.Cells[1,n2]);
   Y2:=StrToFloat(DaonsTable.Cells[2,n2]);
   Z2:=StrToFloat(DaonsTable.Cells[3,n2]);

   D:=Sqrt((Sqr(X2-X1))+(Sqr(Y2-Y1))+(Sqr(Z2-Z1)));
   EditResult2.Text:='0';
   EditResult2.Text:=FloatToStr(D);
end;

procedure TEditDlg.Reset2Click(Sender: TObject);
begin
EditCal2Part1.Text:='0'; EditCal2Part2.Text:='0'; EditResult2.Text:='0';
end;
//CALCULATION 3
procedure TEditDlg.Calculate3Click(Sender: TObject);
var  n1, n2   :integer;
X1, X2, Y1, Y2, Z1, Z2, D  :extended;

begin

   n1:=StrToInt(EditCal3Part1.Text);
   X1:=StrToFloat(DaonsTable.Cells[1,n1]);
   Y1:=StrToFloat(DaonsTable.Cells[2,n1]);
   Z1:=StrToFloat(DaonsTable.Cells[3,n1]);

   n2:=StrToInt(EditCal3Part2.Text);
   X2:=StrToFloat(DaonsTable.Cells[1,n2]);
   Y2:=StrToFloat(DaonsTable.Cells[2,n2]);
   Z2:=StrToFloat(DaonsTable.Cells[3,n2]);

   D:=Sqrt((Sqr(X2-X1))+(Sqr(Y2-Y1))+(Sqr(Z2-Z1)));
   EditResult3.Text:='0';
   EditResult3.Text:=FloatToStr(D);
end;

procedure TEditDlg.Reset3Click(Sender: TObject);
begin
EditCal3Part1.Text:='0'; EditCal3Part2.Text:='0'; EditResult3.Text:='0';
end;
//CALCULATION 4
procedure TEditDlg.Calculate4Click(Sender: TObject);
var  n1, n2   :integer;
X1, X2, Y1, Y2, Z1, Z2, D  :extended;

begin

   n1:=StrToInt(EditCal4Part1.Text);
   X1:=StrToFloat(DaonsTable.Cells[1,n1]);
   Y1:=StrToFloat(DaonsTable.Cells[2,n1]);
   Z1:=StrToFloat(DaonsTable.Cells[3,n1]);

   n2:=StrToInt(EditCal4Part2.Text);
   X2:=StrToFloat(DaonsTable.Cells[1,n2]);
   Y2:=StrToFloat(DaonsTable.Cells[2,n2]);
   Z2:=StrToFloat(DaonsTable.Cells[3,n2]);

   D:=Sqrt((Sqr(X2-X1))+(Sqr(Y2-Y1))+(Sqr(Z2-Z1)));
   EditResult4.Text:='0';
   EditResult4.Text:=FloatToStr(D);
end;

procedure TEditDlg.Reset4Click(Sender: TObject);
begin
EditCal4Part1.Text:='0'; EditCal4Part2.Text:='0'; EditResult4.Text:='0';
end;
//*******************************

//*******************************

//CALCULATION 5
procedure TEditDlg.Calculate5Click(Sender: TObject);
var  n1, n2, n3   :integer;
X1, X2, X3, X4, Y1, Y2, Y3, Y4, Z1, Z2, Z3, Z4,
Xp, Yp, Zp, m, n, q, Ao, Bo, Co, De, D  :extended;

begin

   n1:=StrToInt(EditCal5Part1.Text);
   X1:=StrToFloat(DaonsTable.Cells[1,n1]);
   Y1:=StrToFloat(DaonsTable.Cells[2,n1]);
   Z1:=StrToFloat(DaonsTable.Cells[3,n1]);

   n2:=StrToInt(EditCal5Part2.Text);
   X2:=StrToFloat(DaonsTable.Cells[1,n2]);
   Y2:=StrToFloat(DaonsTable.Cells[2,n2]);
   Z2:=StrToFloat(DaonsTable.Cells[3,n2]);

   n3:=StrToInt(EditCal5Part3.Text);
   X3:=StrToFloat(DaonsTable.Cells[1,n3]);
   Y3:=StrToFloat(DaonsTable.Cells[2,n3]);
   Z3:=StrToFloat(DaonsTable.Cells[3,n3]);


   D:=Sqrt((Sqr(X2-X1))+(Sqr(Y2-Y1))+(Sqr(Z2-Z1)));
   Xp:=(X1+X2+X3)/3; Yp:=(Y1+Y2+Y3)/3; Zp:=(Z1+Z2+Z3)/3;
   m:=(Yp-Y1)*(Zp-Z2)-(Zp-Z1)*(Yp-Y2);
   n:=(Zp-Z1)*(Xp-X2)-(Xp-X1)*(Zp-Z2);
   q:=(Xp-X1)*(Yp-Y2)-(Yp-Y1)*(Xp-X2);
   Ao:=Sqr(m/q)+Sqr(n/q)+1;
   Bo:=(2/q)*(m*(q*Xp-m*Zp)/q+n*(q*Yp-n*Zp)/q-(m*X1+n*Y1+q*Z1));
   Co:=Sqr(m*Zp/q-Xp)+Sqr(n*Zp/q-Yp)+2*X1*(m*Zp/q-Xp)+
       2*Y1*(n*Zp/q-Yp)+Sqr(X1)+Sqr(Y1)+Sqr(Z1)-Sqr(D);
   De:=Sqrt(abs(Sqr(Bo)-4*Ao*Co));

   if EditDlg.Del.Checked  then
      begin
         Z4:=(-Bo+De)/(2*Ao);
      end
      else
      begin
        Z4:=(-Bo-De)/(2*Ao);
      end;

   X4:=m*(Z4-Zp)/q+Xp;
   Y4:=n*(Z4-Zp)/q+Yp;

   EditResultX4.Text:='0'; EditResultY4.Text:='0';
   EditResultZ4.Text:='0';
   EditResultX4.Text:=FloatToStr(X4);
   EditResultY4.Text:=FloatToStr(Y4);
   EditResultZ4.Text:=FloatToStr(Z4);

   EditX.Text:=FloatToStr(X4);
   EditY.Text:=FloatToStr(Y4);
   EditZ.Text:=FloatToStr(Z4);

   EditV.Text:='0';
   EditU.Text:='0';
   EditW.Text:='0';

end;


procedure TEditDlg.Reset5Click(Sender: TObject);
begin
EditCal5Part1.Text:='0'; EditCal5Part2.Text:='0'; EditCal5Part3.Text:='0';
EditResultX4.Text:='0'; EditResultY4.Text:='0'; EditResultZ4.Text:='0';
EditX.Text:='0'; EditY.Text:='0'; EditZ.Text:='0';
end;

(*//***************************
procedure TEditDlg.DataToCelClick(Sender: TObject);
var  n4   :integer;
      X4, Y4, Z4  :extended;
begin
with EditDlg do
     with DaonsTable do
     if not VeloCity
     then
   begin
   n4:=StrToInt(EditCal5Part3.Text);
 //  n4:=StrToInt(EditToCel.Text);

   Cells[1,n4]:=EditX.Text:=;
   Cells[2,n4]:=EditY.Text;
   Cells[3,n4]:=EditZ.Text;
   end
   else
   begin
   Cells[1,n4]:='0';
   Cells[2,n4]:='0';
   Cells[3,n4]:='0';
   end;
end;
//********************************        *)

procedure TEditDlg.DaonsTableSelectCell(Sender: TObject; ACol,
  ARow: Integer; var CanSelect: Boolean);
begin
NumberOfTaon.Caption:=IntToStr(DaonsTable.Row);
EditX.Text:=FloatToStr(Xo[DaonsTable.Row]);
EditY.Text:=FloatToStr(Yo[DaonsTable.Row]);
EditZ.Text:=FloatToStr(Zo[DaonsTable.Row]);
EditV.Text:=FloatToStr(Vo[DaonsTable.Row]);
EditU.Text:=FloatToStr(Uo[DaonsTable.Row]);
EditW.Text:=FloatToStr(Wo[DaonsTable.Row]);
if Dao[DaonsTable.Row]
   then DaoTrue.Checked:=true
   else DaoTrue.Checked:=false;
end;

procedure TEditDlg.FormPaint(Sender: TObject);
begin
EditFileName.Text:=ThisName;
NumberOfTaon.Caption:=IntToStr(DaonsTable.Row);
EditX.Text:=FloatToStr(Xo[DaonsTable.Row]);
EditY.Text:=FloatToStr(Yo[DaonsTable.Row]);
EditZ.Text:=FloatToStr(Zo[DaonsTable.Row]);
EditV.Text:=FloatToStr(Vo[DaonsTable.Row]);
EditU.Text:=FloatToStr(Uo[DaonsTable.Row]);
EditW.Text:=FloatToStr(Wo[DaonsTable.Row]);
if Dao[DaonsTable.Row]
   then DaoTrue.Checked:=true
   else DaoTrue.Checked:=false;
   EditDT.Text:=FloatToStr(dt);
   EditA1.Text:=FloatToStr(A1);
   EditB1.Text:=FloatToStr(B1);
   EditC1.Text:=FloatToStr(C1);
   EditD1.Text:=FloatToStr(D1);
   EditF1.Text:=FloatToStr(F1);
   EditG1.Text:=FloatToStr(G1);
   EditA2.Text:=FloatToStr(A2);
   EditB2.Text:=FloatToStr(B2);
   EditC2.Text:=FloatToStr(C2);
   EditD2.Text:=FloatToStr(D2);
   EditF2.Text:=FloatToStr(F2);
   EditG2.Text:=FloatToStr(G2);
   EditA3.Text:=FloatToStr(A3);
   EditB3.Text:=FloatToStr(B3);
   EditC3.Text:=FloatToStr(C3);
   EditD3.Text:=FloatToStr(D3);
   EditF3.Text:=FloatToStr(F3);
   EditG3.Text:=FloatToStr(G3);

ShowTable1;
end;

  //  ************
procedure TEditDlg.SubmitClick(Sender: TObject);
var n:integer;
begin
n:=StrToInt(NumberOfTaon.Caption);
Xo[n]:=StrToFloat(EditX.Text);
Yo[n]:=StrToFloat(EditY.Text);
Zo[n]:=StrToFloat(EditZ.Text);
Vo[n]:=StrToFloat(EditV.Text);
Uo[n]:=StrToFloat(EditU.Text);
Wo[n]:=StrToFloat(EditW.Text);
if DaoTrue.Checked
   then Dao[n]:=true
   else Dao[n]:=false;
ShowTable1;
end;

procedure TEditDlg.OKBtnClick(Sender: TObject);
var n:integer;
begin
if SaveDialog.Execute then
begin
// SaveFile
dt:=StrToFloat(EditDT.Text);
A1:=StrToFloat(EditA1.Text);
B1:=StrToFloat(EditB1.Text);
C1:=StrToFloat(EditC1.Text);
D1:=StrToFloat(EditD1.Text);
F1:=StrToFloat(EditF1.Text);
G1:=StrToFloat(EditG1.Text);
A2:=StrToFloat(EditA2.Text);
B2:=StrToFloat(EditB2.Text);
C2:=StrToFloat(EditC2.Text);
D2:=StrToFloat(EditD2.Text);
F2:=StrToFloat(EditF2.Text);
G2:=StrToFloat(EditG2.Text);
A3:=StrToFloat(EditA3.Text);
B3:=StrToFloat(EditB3.Text);
C3:=StrToFloat(EditC3.Text);
D3:=StrToFloat(EditD3.Text);
F3:=StrToFloat(EditF3.Text);
G3:=StrToFloat(EditG3.Text);
SaveDataOfTaons;
AssignFile(FTaons,SaveDialog.FileName);
Rewrite(FTaons);
Write(FTaons, Taons);
CloseFile(FTaons);
// end SaveFile
ThisName:=SaveDialog.FileName;
StartFile:=ThisName;
{$I-}
Rewrite(FStartFile);
{$I+}
Write(FStartFile,StartFile);
CloseFile(FStartFile);

dt:=StrToFloat(EditDT.Text);
A1:=StrToFloat(EditA1.Text);
B1:=StrToFloat(EditB1.Text);
C1:=StrToFloat(EditC1.Text);
D1:=StrToFloat(EditD1.Text);
F1:=StrToFloat(EditF1.Text);
G1:=StrToFloat(EditG1.Text);
A2:=StrToFloat(EditA2.Text);
B2:=StrToFloat(EditB2.Text);
C2:=StrToFloat(EditC2.Text);
D2:=StrToFloat(EditD2.Text);
F2:=StrToFloat(EditF2.Text);
G2:=StrToFloat(EditG2.Text);
A3:=StrToFloat(EditA3.Text);
B3:=StrToFloat(EditB3.Text);
C3:=StrToFloat(EditC3.Text);
D3:=StrToFloat(EditD3.Text);
F3:=StrToFloat(EditF3.Text);
G3:=StrToFloat(EditG3.Text);
for n:=1 to MaxTaons do
    if Dao[n] then
       begin
            x[n]:=Xo[n];Xn[n]:=Xo[n];
            y[n]:=Yo[n];Yn[n]:=Yo[n];
            z[n]:=Zo[n];Zn[n]:=Zo[n];
            Vn[n]:=Vo[n];
            Un[n]:=Uo[n];
            Wn[n]:=Wo[n];
       end;
end;//SaveDialog
end;

procedure TEditDlg.SaveasClick(Sender: TObject);
begin
if SaveDialog.Execute then
   begin
   EditFileName.Text:=SaveDialog.FileName;
   dt:=StrToFloat(EditDT.Text);
   A1:=StrToFloat(EditA1.Text);
   B1:=StrToFloat(EditB1.Text);
   C1:=StrToFloat(EditC1.Text);
   D1:=StrToFloat(EditD1.Text);
   F1:=StrToFloat(EditF1.Text);
   G1:=StrToFloat(EditG1.Text);
   A2:=StrToFloat(EditA2.Text);
   B2:=StrToFloat(EditB2.Text);
   C2:=StrToFloat(EditC2.Text);
   D2:=StrToFloat(EditD2.Text);
   F2:=StrToFloat(EditF2.Text);
   G2:=StrToFloat(EditG2.Text);
   A3:=StrToFloat(EditA3.Text);
   B3:=StrToFloat(EditB3.Text);
   C3:=StrToFloat(EditC3.Text);
   D3:=StrToFloat(EditD3.Text);
   F3:=StrToFloat(EditF3.Text);
   G3:=StrToFloat(EditG3.Text);
   SaveDataOfTaons;
   AssignFile(FTaons,SaveDialog.FileName);
   Rewrite(FTaons);
   Write(FTaons, Taons);
   CloseFile(FTaons);
   end;
end;

procedure TEditDlg.DaonsTableClick(Sender: TObject);
begin
NumberOfTaon.Caption:=IntToStr(DaonsTable.Row);
EditX.Text:=FloatToStr(Xo[DaonsTable.Row]);
EditY.Text:=FloatToStr(Yo[DaonsTable.Row]);
EditZ.Text:=FloatToStr(Zo[DaonsTable.Row]);
EditV.Text:=FloatToStr(Vo[DaonsTable.Row]);
EditU.Text:=FloatToStr(Uo[DaonsTable.Row]);
EditW.Text:=FloatToStr(Wo[DaonsTable.Row]);
if Dao[DaonsTable.Row]
   then DaoTrue.Checked:=true
   else DaoTrue.Checked:=false;
ShowTable1;

end;

end.
*****************************************
unit about;

interface

uses Windows, SysUtils, Classes, Graphics, Forms, Controls, StdCtrls,
  Buttons, ExtCtrls;

type
  TAboutBox = class(TForm)
    OKButton: TButton;
    Panel1: TPanel;
    ProgramIcon: TImage;
    ProductName: TLabel;
    Version: TLabel;
    Copyright: TLabel;
    Autor: TLabel;
    Image1: TImage;
    MyHomePage: TLabel;
    Software: TLabel;
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  AboutBox: TAboutBox;

implementation

{$R *.DFM}

end.
 ***********************************