public void takeOff(DifferentialMeanings d, IntegralMeanings S, Forses F, Moments M, Controls del, Statics s)
        {
            d.Vx   = (1 / s.m) * F.x;
            d.BETA = (1 / (s.m * S.Vx)) * F.z + S.Wy;
            d.Wy   = 1 / s.Iyy * M.y;
            d.X    = S.Vx * cos(S.BETA);
            d.Z    = -S.Vx * sin(S.BETA);

            S.Y = s.Cyo * S.q * s.S;
            S.Q = s.Cxo * S.q * s.S;

            F.x = 20 * del.Tr - S.Q - (s.G - S.Y) * (s.froll + s.fslip * (s.InhibitionL + s.InhibitionR));
            F.z = F.zBETA * S.BETA + F.zDELn * del.n + F.zt;

            F.zBETA = s.Cz_BETA * s.S * S.q;
            F.zDELn = s.Cz_del_n * s.S * S.q;
            F.zt    = (s.G - S.Y) * s.Czk_BETA * (S.BETA + s.fW * del.fW);

            M.y = M.yz + M.yWy + M.yp + M.yt;

            M.yz  = s.my_BETA * S.q * s.S * s.L * S.BETA + s.my_DELn * del.n;
            M.yWy = s.my_Wy * S.q * s.S * s.L * d.Wy;
            M.yp  = 0; // = (P1 - P2) * s.Zengine
            M.yt  = (s.fW * s.XfrontWheel * del.fW + s.fslip * (s.G - S.Y) * (s.InhibitionL + s.InhibitionR) * (s.Zchassis / 2));

            S.q = (s.PO_h * S.Vx * S.Vx / 2);

            d.Xg = S.Vx * cos(S.BETA);
        }
        public void dynLinear(DifferentialMeanings d, IntegralMeanings S, LinearizedCoefficient c, Controls del, Statics s)
        {
            d.THETA_DEL      = S.Wz_DEL;
            d.Wz_DEL         = -c.c1 * d.THETA_DEL - c.c2 * S.ALPHA_DEL - c.c5 * d.ALPHA_DEL - c.c3 * del.e_rv_DEL;
            d.THETA_PATH_DEL = c.c4 * S.ALPHA_DEL + c.c9 * del.e_rv_DEL;
            d.ALPHA_DEL      = d.THETA_DEL - d.THETA_PATH_DEL;
            d.Yg_DEL         = c.c6 * S.THETA_PATH_DEL;

            d.GAMA_DEL = S.Wx_DEL;
            d.Wy_DEL   = -c.a1 * S.Wy_DEL - c.b6 * S.Wx_DEL - c.a2 * S.BETA_DEL - c.a3 * del.n_DEL - c.b5 * del.e_DEL;
            d.PSI_DEL  = S.Wy_DEL;
            d.Wx_DEL   = -c.a6 * S.Wy_DEL - c.b1 * S.Wx_DEL - c.b2 * S.BETA_DEL - c.a5 * del.n_DEL - c.b3 * del.e_DEL;
            d.BETA_DEL = S.Wy_DEL + c.b7 * S.Wx_DEL - c.b4 * S.PSI_DEL - c.a4 * S.BETA_DEL - c.a7 * del.n_DEL;
        }
        public void dynFullDiff(DifferentialMeanings d, IntegralMeanings S, LinearizedCoefficient c, Controls del, Statics s)
        {
            S.q = (s.PO_h * S.V * S.V) / 2;

            d.THETA      = S.Wz;
            d.THETA_PATH = c.c4 * S.ALPHA + c.c9 * del.e_rv;
            d.Wz         = -c.c1 * S.Wz - c.c2 * S.ALPHA - c.c3 * del.e_rv - c.c5 * d.ALPHA;
            d.ALPHA      = d.THETA - d.THETA_PATH;

            d.GAMA = S.Wx;
            d.Wy   = -c.a1 * S.Wy - c.b6 * S.Wx - c.a2 * S.BETA - c.a3 * del.n - c.b5 * del.e;
            d.PSI  = S.Wy;
            d.Wx   = -c.a6 * S.Wy - c.b1 * S.Wx - c.b2 * S.BETA - c.a5 * del.n - c.b3 * del.e;
            d.BETA = S.Wy + c.b7 * S.Wx - c.b4 * S.PSI - c.a4 * S.BETA - c.a7 * del.n;
        }
        public void setRealParamValuesFromIncrements(IntegralMeanings S, DifferentialMeanings d, Controls del)
        {
            S.V = S.V_BAL + S.V_DEL;

            S.Wx = S.Wx_BAL + S.Wx_DEL;
            S.Wy = S.Wy_BAL + S.Wy_DEL;
            S.Wz = S.Wz_BAL + S.Wz_DEL;

            S.Xg = S.Xg_BAL + S.Xg_DEL;
            S.Yg = S.Yg_BAL + S.Yg_DEL;
            S.Zg = S.Zg_BAL + S.Zg_DEL;

            S.GAMA = S.GAMA_BAL + S.GAMA_DEL;
            S.PSI  = S.PSI_BAL + S.PSI_DEL;

            S.THETA      = S.THETA_BAL + S.THETA_DEL;
            S.THETA_PATH = S.THETA_PATH_BAL + S.THETA_PATH_DEL;

            S.ALPHA = S.ALPHA_BAL + S.ALPHA_DEL;
            S.BETA  = S.BETA_BAL + S.BETA_DEL;

            d.Wx = d.Wx_DEL;
            d.Wy = d.Wy_DEL;
            d.Wz = d.Wz_DEL;

            d.Xg = d.Xg_DEL;
            d.Yg = d.Yg_DEL;
            d.Zg = d.Zg_DEL;

            d.GAMA = d.GAMA_DEL;
            d.PSI  = d.PSI_DEL;

            d.THETA      = d.THETA_DEL;
            d.THETA_PATH = d.THETA_PATH_DEL;

            d.ALPHA = d.ALPHA_DEL;
            d.BETA  = d.BETA_DEL;

            del.e    = del.e_DEL + del.e_BAL;
            del.n    = del.n_DEL + del.n_BAL;
            del.e_rv = del.e_rv_DEL + del.e_rv_BAL;
            del.Tr   = del.Tr_DEL + del.Tr_BAL;
        }
        /// <summary>
        /// Получаем диф значения после отработки модели
        /// </summary>
        /// <param name="d">Диф значения</param>
        /// <param name="n">Размерность модели</param>
        public Double[] getDiffValuesIncrements(DifferentialMeanings d, int n)
        {
            Double[] X = new Double[n];

            X[0] = d.Wx_DEL;
            X[1] = d.Wy_DEL;
            X[2] = d.Wz_DEL;

            X[3] = d.PSI_DEL;

            X[4] = d.GAMA_DEL;
            X[5] = d.THETA_DEL;
            X[6] = d.THETA_PATH_DEL;

            X[7] = d.ALPHA_DEL;
            X[8] = d.BETA_DEL;

            X[9] = d.Yg_DEL;


            return(X);
        }
        /// <summary>
        /// Получаем диф значения после отработки модели
        /// </summary>
        /// <param name="d">Диф значения</param>
        /// <param name="n">Размерность модели</param>
        public Double[] getDiffValues(DifferentialMeanings d, int n)
        {
            Double[] X = new Double[n];

            X[0] = d.Wx;
            X[1] = d.Wy;
            X[2] = d.Wz;

            X[3] = d.PSI;

            X[4] = d.GAMA;
            X[5] = d.THETA;
            X[6] = d.THETA_PATH;

            X[7] = d.ALPHA;
            X[8] = d.BETA;

            X[9] = d.Yg;


            return(X);
        }
        /// <summary>
        /// Set initial conditions
        /// </summary>
        public void SetInitialConditions()
        {
            d = new DifferentialMeanings();
            S = new IntegralMeanings();
            F = new Forses();
            M = new Moments();
            C = new Coefficient();
            c = new LinearizedCoefficient();
            N = new Overload();
            del = new Controls();
            s = new Statics();

            SetInitialValues();

            if (stForm == null)
            { stForm = new StaticsForm(this, s); }
            else if (stForm != null)
            {
                stForm.Close();
                stForm = new StaticsForm(this, s);
            }

            if (fpForm == null)
            { fpForm = new FlyParamForm(this); }
            else if (fpForm != null)
            {
                fpForm.Close();
                fpForm = new FlyParamForm(this);
            }

            if (glForm == null)
            { glForm = new GraphicsListForm(this); }
            else if (glForm != null)
            {
                glForm.Close();
                glForm = new GraphicsListForm(this);
            }

            if (dgForm == null)
            { dgForm = new DataGridForm(this); }
            else if (dgForm != null)
            {
                dgForm.Close();
                dgForm = new DataGridForm(this);
            }

            if (avForm == null)
            { avForm = new AviatingForm(this); }
            else if (avForm != null)
            {
                avForm.Close();
                avForm = new AviatingForm(this);
            }

            if (pvForm == null)
            { pvForm = new PlaneVisualisationForm(this.toolStripButton6_Visualisation, S); }
            else if (pvForm != null)
            {
                pvForm.Close();
                pvForm = new PlaneVisualisationForm(this.toolStripButton6_Visualisation, S);
            }

            if (auForm == null)
            { auForm = new AutopilotForm(this); }
            else if (auForm != null)
            {
                auForm.Close();
                auForm = new AutopilotForm(this);
            }

            if (scrForm == null)
            { scrForm = new ScriptingAutopilotForm(this); }
            else if (scrForm != null)
            {
                scrForm.Close();
                scrForm = new ScriptingAutopilotForm(this);
            }
        }
        public void takeOff(DifferentialMeanings d, IntegralMeanings S, Forses F, Moments M, Controls del, Statics s)
        {
            d.Vx = (1 / s.m) * F.x;
            d.BETA = (1 / (s.m * S.Vx)) * F.z + S.Wy;
            d.Wy = 1 / s.Iyy * M.y;
            d.X = S.Vx * cos(S.BETA);
            d.Z = -S.Vx * sin(S.BETA);

            S.Y = s.Cyo * S.q * s.S;
            S.Q = s.Cxo * S.q * s.S;

            F.x = 20 * del.Tr - S.Q - (s.G - S.Y) * (s.froll + s.fslip * (s.InhibitionL + s.InhibitionR));
            F.z = F.zBETA * S.BETA + F.zDELn * del.n + F.zt;

            F.zBETA = s.Cz_BETA * s.S * S.q;
            F.zDELn = s.Cz_del_n * s.S * S.q;
            F.zt = (s.G - S.Y) * s.Czk_BETA * (S.BETA + s.fW * del.fW);

            M.y = M.yz + M.yWy + M.yp + M.yt;

            M.yz = s.my_BETA * S.q * s.S * s.L * S.BETA + s.my_DELn * del.n;
            M.yWy = s.my_Wy * S.q * s.S * s.L * d.Wy;
            M.yp = 0; // = (P1 - P2) * s.Zengine
            M.yt = (s.fW * s.XfrontWheel * del.fW + s.fslip * (s.G - S.Y) * (s.InhibitionL + s.InhibitionR) * (s.Zchassis / 2));

            S.q = (s.PO_h * S.Vx * S.Vx / 2);

            d.Xg = S.Vx * cos(S.BETA);
        }
        public void setRealParamValuesFromIncrements(IntegralMeanings S, DifferentialMeanings d, Controls del)
        {
            S.V = S.V_BAL + S.V_DEL;

            S.Wx = S.Wx_BAL + S.Wx_DEL;
            S.Wy = S.Wy_BAL + S.Wy_DEL;
            S.Wz = S.Wz_BAL + S.Wz_DEL;

            S.Xg = S.Xg_BAL + S.Xg_DEL;
            S.Yg = S.Yg_BAL + S.Yg_DEL;
            S.Zg = S.Zg_BAL + S.Zg_DEL;

            S.GAMA = S.GAMA_BAL + S.GAMA_DEL;
            S.PSI = S.PSI_BAL + S.PSI_DEL;

            S.THETA = S.THETA_BAL + S.THETA_DEL;
            S.THETA_PATH = S.THETA_PATH_BAL + S.THETA_PATH_DEL;

            S.ALPHA = S.ALPHA_BAL + S.ALPHA_DEL;
            S.BETA = S.BETA_BAL + S.BETA_DEL;

            d.Wx = d.Wx_DEL;
            d.Wy = d.Wy_DEL;
            d.Wz = d.Wz_DEL;

            d.Xg = d.Xg_DEL;
            d.Yg = d.Yg_DEL;
            d.Zg = d.Zg_DEL;

            d.GAMA = d.GAMA_DEL;
            d.PSI = d.PSI_DEL;

            d.THETA = d.THETA_DEL;
            d.THETA_PATH = d.THETA_PATH_DEL;

            d.ALPHA = d.ALPHA_DEL;
            d.BETA = d.BETA_DEL;

            del.e = del.e_DEL + del.e_BAL;
            del.n = del.n_DEL + del.n_BAL;
            del.e_rv = del.e_rv_DEL + del.e_rv_BAL;
            del.Tr = del.Tr_DEL + del.Tr_BAL;
        }
        /// <summary>
        /// Получаем диф значения после отработки модели
        /// </summary>
        /// <param name="d">Диф значения</param>
        /// <param name="n">Размерность модели</param>
        public Double[] getDiffValuesIncrements(DifferentialMeanings d, int n)
        {
            Double[] X = new Double[n];

            X[0] = d.Wx_DEL;
            X[1] = d.Wy_DEL;
            X[2] = d.Wz_DEL;

            X[3] = d.PSI_DEL;

            X[4] = d.GAMA_DEL;
            X[5] = d.THETA_DEL;
            X[6] = d.THETA_PATH_DEL;

            X[7] = d.ALPHA_DEL;
            X[8] = d.BETA_DEL;

            X[9] = d.Yg_DEL;

            return (X);
        }
        /// <summary>
        /// Получаем диф значения после отработки модели
        /// </summary>
        /// <param name="d">Диф значения</param>
        /// <param name="n">Размерность модели</param>
        public Double[] getDiffValues(DifferentialMeanings d, int n)
        {
            Double[] X =  new Double[n];

             X[0] = d.Wx;
             X[1] = d.Wy;
             X[2] = d.Wz;

             X[3] = d.PSI;

             X[4] = d.GAMA;
             X[5] = d.THETA;
             X[6] = d.THETA_PATH;

             X[7] = d.ALPHA;
             X[8] = d.BETA;

             X[9] = d.Yg;

            return (X);
        }
        public void dynLinear(DifferentialMeanings d, IntegralMeanings S, LinearizedCoefficient c, Controls del, Statics s)
        {
            d.THETA_DEL = S.Wz_DEL;
            d.Wz_DEL = -c.c1 * d.THETA_DEL - c.c2 * S.ALPHA_DEL - c.c5 * d.ALPHA_DEL - c.c3 * del.e_rv_DEL;
            d.THETA_PATH_DEL = c.c4 * S.ALPHA_DEL + c.c9 * del.e_rv_DEL;
            d.ALPHA_DEL = d.THETA_DEL - d.THETA_PATH_DEL;
            d.Yg_DEL = c.c6 * S.THETA_PATH_DEL;

            d.GAMA_DEL = S.Wx_DEL;
            d.Wy_DEL = -c.a1 * S.Wy_DEL - c.b6 * S.Wx_DEL - c.a2 * S.BETA_DEL - c.a3 * del.n_DEL - c.b5 * del.e_DEL;
            d.PSI_DEL = S.Wy_DEL;
            d.Wx_DEL = -c.a6 * S.Wy_DEL - c.b1 * S.Wx_DEL - c.b2 * S.BETA_DEL - c.a5 * del.n_DEL - c.b3 * del.e_DEL;
            d.BETA_DEL = S.Wy_DEL + c.b7 * S.Wx_DEL - c.b4 * S.PSI_DEL - c.a4 * S.BETA_DEL - c.a7 * del.n_DEL;
        }
        public void dynFullDiff(DifferentialMeanings d, IntegralMeanings S, LinearizedCoefficient c, Controls del, Statics s)
        {
            S.q = (s.PO_h * S.V * S.V) / 2;

            d.THETA = S.Wz;
            d.THETA_PATH = c.c4 * S.ALPHA + c.c9 * del.e_rv;
            d.Wz = -c.c1 * S.Wz - c.c2 * S.ALPHA - c.c3 * del.e_rv - c.c5 * d.ALPHA;
            d.ALPHA = d.THETA - d.THETA_PATH;

            d.GAMA = S.Wx;
            d.Wy = -c.a1 * S.Wy - c.b6 * S.Wx - c.a2 * S.BETA - c.a3 * del.n - c.b5 * del.e;
            d.PSI = S.Wy;
            d.Wx = -c.a6 * S.Wy - c.b1 * S.Wx - c.b2 * S.BETA - c.a5 * del.n - c.b3 * del.e;
            d.BETA = S.Wy + c.b7 * S.Wx - c.b4 * S.PSI - c.a4 * S.BETA - c.a7 * del.n;
        }