Пример #1
0
        public void getData(double a1, double a2)
        {
            double a3 = 0;



            dgdView2.DataSource = null;
            string time = DateTime.Now.ToLongTimeString();

            variables v1 = new variables(time, a1, a2, a3);


            xy.Add(v1);

            dgdView2.DataSource = xy;
        }
Пример #2
0
        private void Solve_Click(object sender, EventArgs e)
        {
            lblError.Text = "";

            double a11 = Convert.ToDouble(t11.Text), a12 = Convert.ToDouble(t12.Text), a13 = Convert.ToDouble(t13.Text);
            double a21 = Convert.ToDouble(t21.Text), a22 = Convert.ToDouble(t22.Text), a23 = Convert.ToDouble(t23.Text);
            double a31 = Convert.ToDouble(t31.Text), a32 = Convert.ToDouble(t32.Text), a33 = Convert.ToDouble(t33.Text);

            double ad11 = ((a22 * a33) - (a23 * a32));
            double ad12 = -((a21 * a33) - (a23 * a31));
            double ad13 = ((a21 * a32) - (a22 * a31));
            double ad21 = -((a12 * a33) - (a32 * a13));
            double ad22 = ((a11 * a33) - (a31 * a13));
            double ad23 = -((a11 * a32) - (a31 * a12));
            double ad31 = ((a12 * a23) - (a13 * a22));
            double ad32 = -((a11 * a23) - (a21 * a13));
            double ad33 = ((a11 * a22) - (a12 * a21));


            double sf1 = a11 * ((a22 * a33) - (a23 * a32));
            double sf2 = a12 * ((a21 * a33) - (a23 * a31));
            double sf3 = a13 * ((a21 * a32) - (a22 * a31));

            double A = sf1 - sf2 + sf3;



            double a1 = Convert.ToDouble(t14.Text); double a2 = Convert.ToDouble(t24.Text); double a3 = Convert.ToDouble(t34.Text);



            double c11 = ad11;   double c12 = ad21; double c13 = ad31;

            double c22 = ad22; double c21 = ad12; double c23 = ad32;

            double c33 = ad33; double c31 = ad13; double c32 = ad23;


            c11 = c11 / A;
            c12 = c12 / A;
            c13 = c13 / A;
            c21 = c21 / A;
            c22 = c22 / A;
            c23 = c23 / A;
            c31 = c31 / A;
            c32 = c32 / A;
            c33 = c33 / A;



            double f1 = (c11 * a1) + (c12 * a2) + (c13 * a3); f1 = Math.Round(f1, 3);
            double f2 = (c21 * a1) + (c22 * a2) + (c23 * a3); f2 = Math.Round(f2, 3);
            double f3 = (c31 * a1) + (c32 * a2) + (c33 * a3); f3 = Math.Round(f3, 3);


            txtX.Text = Convert.ToString(f1);
            txtY.Text = Convert.ToString(f2);
            txtZ.Text = Convert.ToString(f3);


            if (txtX.Text == "NaN" || txtY.Text == "NaN" || txtZ.Text == "NaN")
            {
                lblError.Text = "If the output is NaN, it means either the equations have no solution or you have enterred a wrong Input";
            }

            if (chkSave.Checked)
            {
                string time = DateTime.Now.ToLongTimeString();

                variables v1 = new variables(time, f1, f2, f3);
                dgdView.DataSource = null;


                xyz.Add(v1);

                dgdView.DataSource = xyz;
            }
        }