Esempio n. 1
0
 /// <summary>
 /// Вычисления корней в обработчике
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void InHandler_Click(object sender, EventArgs e)
 {
     if (TextA.Text != "" && TextB.Text != "" && TextC.Text != "" &&
         TextA.Text != "-" && TextB.Text != "-" && TextC.Text != "-" &&
         TextA.Text != "+" && TextB.Text != "+" && TextC.Text != "+" &&
         TextA.Text != "," && TextB.Text != "," && TextC.Text != ",")
     {
         double D, X1, X2, a, b, c;
         a = double.Parse(TextA.Text);
         b = double.Parse(TextB.Text);
         c = double.Parse(TextC.Text);
         D = b * b - 4 * a * c;
         if (D >= 0)
         {
             X1          = (-1 * b + Math.Sqrt(D)) / (2 * a);
             X2          = (-1 * b - Math.Sqrt(D)) / (2 * a);
             TextX1.Text = X1.ToString("F4");
             TextX2.Text = X2.ToString("F4");
         }
         else
         {
             string comp_x1, comp_x2;
             comp_x1 = (-1 * b / (2 * a)).ToString("F4") + "+" +
                       (Math.Sqrt(-1 * D) / (2 * a)).ToString("F4") + "i";
             comp_x2 = (-1 * b / (2 * a)).ToString("F4") + "-" +
                       (Math.Sqrt(-1 * D) / (2 * a)).ToString("F4") + "i";
             TextX1.Text = comp_x1;
             TextX2.Text = comp_x2;
         }
     }
     else
     {
         Error.Text = "Ошибка, не все поля заполнены! \nЛибо неверный формат вводимых данных!";
     }
 }
Esempio n. 2
0
        static void Main(string[] args)
        {
            for (int k = 0; k < 4; k++)
            {
                double A, B, C, delta, X1, X2;

                string[] s = Console.ReadLine().Split(' ');
                A = double.Parse(s[0]);
                B = double.Parse(s[1]);
                C = double.Parse(s[2]);

                if (A == 0)
                {
                    Console.WriteLine("Impossivel calcular");
                }
                else
                {
                    delta = Math.Pow(B, 2.0) - (4.0 * A * C);
                    if (delta < 0)
                    {
                        Console.WriteLine("Impossivel calcular");
                    }
                    else
                    {
                        X1 = (-B + Math.Sqrt(delta)) / (2.0 * A);
                        X2 = (-B - Math.Sqrt(delta)) / (2.0 * A);
                        Console.WriteLine("X1 = " + X1.ToString("F5"));
                        Console.WriteLine("X2 = " + X2.ToString("F5"));
                    }
                }
                Console.WriteLine();
            }
        }
Esempio n. 3
0
		public override void WriteGroupCodes()
		{
			int flags;

			WriteGroupCodeValue(10, X0.ToString().Trim());
			WriteGroupCodeValue(20, Y0.ToString().Trim());
			WriteGroupCodeValue(30, Z0.ToString().Trim());

			WriteGroupCodeValue(11, X1.ToString().Trim());
			WriteGroupCodeValue(21, Y1.ToString().Trim());
			WriteGroupCodeValue(31, Z1.ToString().Trim());

			WriteGroupCodeValue(12, X2.ToString().Trim());
			WriteGroupCodeValue(22, Y2.ToString().Trim());
			WriteGroupCodeValue(32, Z2.ToString().Trim());

			WriteGroupCodeValue(13, X3.ToString().Trim());
			WriteGroupCodeValue(23, Y3.ToString().Trim());
			WriteGroupCodeValue(33, Z3.ToString().Trim());

			flags = 0;

			if(Edge1Invisible) flags += 1;
			if(Edge2Invisible) flags += 2;
			if(Edge3Invisible) flags += 4;
			if(Edge4Invisible) flags += 8;

			WriteGroupCodeValue(70, flags.ToString().Trim());
		}
Esempio n. 4
0
        public static void SaveLog(int itemIndex, string runResult)
        {
            //创建文件夹
            if (!Directory.Exists(logDir))
            {
                Directory.CreateDirectory(logDir);
            }

            var lineVals = new List <string>
            {
                DateTime.Now.ToString("HH:mm:ss"), X1.ToString("f3"), X2.ToString("f3"), Y1.ToString("f3"),
                Y2.ToString("f3"), angle.ToString("f3"),
                runResult, itemIndex.ToString(), " ", X1_pixel.ToString("f3"), X2_pixel.ToString("f3"),
                Y1_pixel.ToString("f3"), Y2_pixel.ToString("f3"),
                angleUncalib.ToString("f3")
            };
            var line = string.Join(",", lineVals);

            try
            {
                csvFile = dataLogger.WriteLine(line);
            }
            catch
            {
                MessageBox.Show("请关闭所有CCD软件产生的文档");
            }

            removeOutdatedFiles(logDir);
        }
Esempio n. 5
0
        public override IEnumerable <SvgAttribute> GetAttributes()
        {
            var baseAttributes = base.GetAttributes();

            if (baseAttributes != null)
            {
                foreach (var attr in baseAttributes)
                {
                    yield return(attr);
                }
            }

            var ci = CultureInfo.InvariantCulture;

            yield return(new SvgAttribute("x1", "0",
                                          () => X1.ToString(ci),
                                          v => X1 = SvgAttribute.ParseFloatAttribute(v)
                                          ));

            yield return(new SvgAttribute("y1", "0",
                                          () => Y1.ToString(ci),
                                          v => Y1 = SvgAttribute.ParseFloatAttribute(v)
                                          ));

            yield return(new SvgAttribute("x2", "0",
                                          () => X2.ToString(ci),
                                          v => X2 = SvgAttribute.ParseFloatAttribute(v)
                                          ));

            yield return(new SvgAttribute("y2", "0",
                                          () => Y2.ToString(ci),
                                          v => Y2 = SvgAttribute.ParseFloatAttribute(v)
                                          ));

            yield return(new SvgAttribute("stroke-width",
                                          () => StrokeWidth.ToString(ci),
                                          v => StrokeWidth = SvgAttribute.ParseFloatAttribute(v)
                                          ));

            yield return(new SvgAttribute("stroke",
                                          () => Stroke == Color.Empty ? "none" : ColorTranslator.ToSvg(Stroke),
                                          v => Stroke = SvgAttribute.ParseColorAttribute(v, Stroke.A)
                                          ));

            yield return(new SvgAttribute("stroke-opacity", "1",
                                          () => ((double)Stroke.A / 255).ToString(ci),
                                          v => Stroke = SvgAttribute.ParseOpacityAttribute(v, Stroke)
                                          ));

            yield return(new SvgAttribute("stroke-dashoffset",
                                          () => StrokeDashOffset.ToString(ci),
                                          v => StrokeDashOffset = SvgAttribute.ParseFloatAttribute(v)
                                          ));

            yield return(new SvgAttribute("stroke-dasharray",
                                          () => DashArrayToString(),
                                          v => StrokeDashArray = SvgAttribute.ParseFloatArray(v)
                                          ));
        }
Esempio n. 6
0
 /// <summary>
 /// Return a string representation of this object.
 /// </summary>
 public override String ToString()
 {
     return(String.Format("Line2D: X1={0}, Y1={1}, X2={2}, Y2={3}",
                          X1.ToString(),
                          Y1.ToString(),
                          X2.ToString(),
                          Y2.ToString()));
 }
Esempio n. 7
0
        public override string ToString()
        {
            string str = "{X1:" + X1.ToString()
                         + ", X2:" + X2.ToString()
                         + ", Y:" + Y.ToString()
                         + ", Z:" + Z.ToString() + "}";

            return("GSA Offset " + str);
        }
Esempio n. 8
0
 private void LastExecutedCommand()
 {
     TbMR2n.Text = N.ToString();
     TbMR2x.Text = X1.ToString();
     TbMR2y.Text = Y1.ToString();
     TbMR2t.Text = T1.ToString();
     TbMR2g.Text = G1.ToString();
     TbMR2l.Text = L1.ToString();
 }
Esempio n. 9
0
 public XElement ToXml(string name)
 {
     return(new XElement(name,
                         new XAttribute("R0", R0.ToString(CultureInfo.InvariantCulture)),
                         new XAttribute("R1", R1.ToString(CultureInfo.InvariantCulture)),
                         new XAttribute("X0", X0.ToString(CultureInfo.InvariantCulture)),
                         new XAttribute("X1", X1.ToString(CultureInfo.InvariantCulture))
                         ));
 }
Esempio n. 10
0
        public override void WriteGroupCodes()
        {
            WriteGroupCodeValue(10, X0.ToString().Trim());
            WriteGroupCodeValue(20, Y0.ToString().Trim());
            WriteGroupCodeValue(30, Z0.ToString().Trim());

            WriteGroupCodeValue(11, X1.ToString().Trim());
            WriteGroupCodeValue(21, Y1.ToString().Trim());
            WriteGroupCodeValue(31, Z1.ToString().Trim());
        }
Esempio n. 11
0
        }//Separamos todos los valores de las X y el lado derecho

        private void Paso2(ListBox ltbSalida, PictureBox cuadro, ListBox ltbSalida2, TextBox txtResultado4)
        {
            for (int i = 0; i < ltsGrafos.N; i++)
            {
                ltsGrafos.mostrarPosicion(i, out object X1, out object X2, out object ld);
                ltsGrafosCoordenadas.insertatFin(Dividir(ld.ToString(), X1.ToString()), Dividir(ld.ToString(), X2.ToString()), 0);
            }
            ltsGrafosCoordenadas.mostrar(ltbSalida);
            Paso3(cuadro, ltbSalida2, txtResultado4);
        }
Esempio n. 12
0
        public override string ToString()
        {
            string str = System.Environment.NewLine
                         + "X1: " + X1.ToString()
                         + ", X2: " + X2.ToString()
                         + ", Y: " + Y.ToString()
                         + ", Z: " + Z.ToString();

            return("GSA Offset" + str);
        }
        public override string ToString()
        {
            string str = "";

            str += X1.ToString() + "\n";
            str += X2.ToString() + "\n";
            str += X3.ToString() + "\n";
            str += $"Area = {Area.ToString("f3")}\nPerimetr = {Perimetr.ToString("f3")}\n";
            return(str);
        }
Esempio n. 14
0
 public void ImprimeValores()
 {
     if (A == 0 || (B * B - 4 * A * C < 0))
     {
         Console.WriteLine("Impossível Calcular");
     }
     else
     {
         X1 = (-B + Math.Sqrt(B * B - 4 * A * C)) / (2 * A);
         X2 = (-B - Math.Sqrt(B * B - 4 * A * C)) / (2 * A);
         Console.WriteLine("X1 = " + X1.ToString("F5", CultureInfo.InvariantCulture));
         Console.WriteLine("X2 = " + X2.ToString("F5", CultureInfo.InvariantCulture));
     }
 }
Esempio n. 15
0
        private bool ParseMoveByte_CheckForEmpty(byte[] move)
        {
            bool check = true;

            if (move == Constants.CMD_EMPTY_DATA)
            {
                check = false;
            }
            X1 = Convert.ToInt32(move[1]);
            Y1 = (Convert.ToInt32(move[2]));
            X2 = (Convert.ToInt32(move[3]));
            Y2 = Convert.ToInt32(move[4]);
            Console.WriteLine(X1.ToString() + " " + Y1.ToString() + " " +
                              X2.ToString() + " " + Y2.ToString());
            return(check);
        }
Esempio n. 16
0
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("SinuousFaultGene [");
            sb.AppendFormat("\n  X0          = {0}", X0.ToString());
            sb.AppendFormat("\n  Y0          = {0}", Y0.ToString());
            sb.AppendFormat("\n  Phi0        = {0}", Phi0.ToString());
            sb.AppendFormat("\n  X1          = {0}", X1.ToString());
            sb.AppendFormat("\n  Y1          = {0}", Y1.ToString());
            sb.AppendFormat("\n  Phi1        = {0}", Phi1.ToString());
            sb.AppendFormat("\n  DetachDepth = {0}", DetachDepth.ToString());
            sb.AppendFormat("\n  MaxHeave    = {0}", MaxHeave.ToString());
            sb.AppendFormat("\n  Dip         = {0}", Dip.ToString());
            sb.Append("\n ]\n");
            return(sb.ToString());
        }
Esempio n. 17
0
        public override void WriteGroupCodes()
        {
            WriteGroupCodeValue(10, X0.ToString().Trim());
            WriteGroupCodeValue(20, Y0.ToString().Trim());
            WriteGroupCodeValue(30, Z0.ToString().Trim());

            WriteGroupCodeValue(11, X1.ToString().Trim());
            WriteGroupCodeValue(21, Y1.ToString().Trim());
            WriteGroupCodeValue(31, Z1.ToString().Trim());

            WriteGroupCodeValue(12, X2.ToString().Trim());
            WriteGroupCodeValue(22, Y2.ToString().Trim());
            WriteGroupCodeValue(32, Z2.ToString().Trim());

            WriteGroupCodeValue(13, X3.ToString().Trim());
            WriteGroupCodeValue(23, Y3.ToString().Trim());
            WriteGroupCodeValue(33, Z3.ToString().Trim());
        }
Esempio n. 18
0
 bool WriteFromGRDECL(string file)
 {
     try
     {
         using (StreamWriter sw = new StreamWriter(file, true))
         {
             sw.WriteLine(string.Empty);
             sw.WriteLine(grdecl_kw_mapaxes);
             sw.WriteLine(X1.ToString() + " " + Y1.ToString() + " " +
                          X2.ToString() + " " + Y2.ToString() + " " +
                          X3.ToString() + " " + Y3.ToString() + " /");
         }
     }
     catch (Exception)
     {
         return(false);
     }
     return(true);
 }
Esempio n. 19
0
        private void button1_Click(object sender, EventArgs e)
        {
            int    A = int.Parse(Value1.Text), B = int.Parse(Value2.Text), C = int.Parse(Value3.Text);
            double X1, X2;
            double calculation = Math.Pow(B, 2) - 4 * A * C;

            if (calculation < 0)
            {
                X1           = (-B + Math.Sqrt(-calculation)) / (2 * A);
                X2           = (-B - Math.Sqrt(-calculation)) / (2 * A);
                Result1.Text = X1.ToString() + "i";
                Result2.Text = X2.ToString() + "i";
            }
            else
            {
                X1           = (-B + Math.Sqrt(calculation)) / (2 * A);
                X2           = (-B - Math.Sqrt(calculation)) / (2 * A);
                Result1.Text = X1.ToString();
                Result2.Text = X2.ToString();
            }
        }
Esempio n. 20
0
        protected override void WriteDataXML(XElement ele, ElderScrollsPlugin master)
        {
            XElement subEle;

            ele.TryPathTo("Point1/X", true, out subEle);
            subEle.Value = X1.ToString();

            ele.TryPathTo("Point1/Y", true, out subEle);
            subEle.Value = Y1.ToString();

            ele.TryPathTo("Point1/Z", true, out subEle);
            subEle.Value = Z1.ToString();

            ele.TryPathTo("Point2/X", true, out subEle);
            subEle.Value = X2.ToString();

            ele.TryPathTo("Point2/Y", true, out subEle);
            subEle.Value = Y2.ToString();

            ele.TryPathTo("Point2/Z", true, out subEle);
            subEle.Value = Z2.ToString();
        }
        public void GetRoot()
        {
            FindPoint();
            Write("Enter Accuracy: ");
            this.accuracy = double.Parse(ReadLine());
            int    step = 1;
            double Xo   = (pointA + pointB) / 2;
            double f;
            double _f = this._f(Xo);
            double X1;
            string update = "";

            WriteLine("{0,-5} | {1,10} | {2,10} | {3,10} | {4,10} | {5,10}", "Step", "Xo", "f(Xo)", "f`(Xo)", "X1", "Update");

            do
            {
                f  = this.f(Xo);
                _f = this._f(Xo);
                X1 = Xo - (f / _f);
                WriteLine("---------------------------------------------------------------------------------------------------");
                WriteLine("{0,-5} | {1,10} | {2,10} | {3,10} | {4,10} | {5,10}",
                          step++, Xo.ToString("0.00000"),
                          f.ToString("0.00000"),
                          _f.ToString("0.00000"),
                          X1.ToString("0.00000"),
                          update);
                if (this.f(X1) == 0)
                {
                    break;
                }
                else
                {
                    Xo = X1;
                }
            }while (this.f(X1) != 0 && Math.Abs(this.f(X1)) >= this.accuracy);
            WriteLine();
            WriteLine($"Approximate root of the equation 2x^3-5x+25 using Newton Raphson method is " +
                      $"{X1:0.000000}");
        }
Esempio n. 22
0
        static void Main(string[] args)
        {
            double a, b, c, X1, X2, delta;

            string[] vet = Console.ReadLine().Split(' ');
            a = double.Parse(vet[0]);
            b = double.Parse(vet[1]);
            c = double.Parse(vet[2]);

            delta = Math.Pow(b, 2.0) - (4.0 * a * c);

            if (a == 0 || delta < 0)
            {
                Console.WriteLine("Impossível calcular");
            }
            else
            {
                X1 = (-b + Math.Sqrt(delta)) / (2.0 * a);
                X2 = (-b - Math.Sqrt(delta)) / (2.0 * a);
                Console.WriteLine("X1 = {0}", X1.ToString("F5"));
                Console.WriteLine("X2 = {0}", X2.ToString("F5"));
            }
        }
Esempio n. 23
0
        /// <summary>
        /// Метод класса, отвечающий за вычисления
        /// </summary>
        /// <param name="a">Первый коэфциент уравнения</param>
        /// <param name="b">Второй коэфициент уравнения</param>
        /// <param name="c">Третий коэфициент уравнения</param>
        /// <returns>Массив строковых представлений корней</returns>
        public string[] Result(double a, double b, double c)
        {
            double D, X1, X2;

            string[] res = new string[2];
            D = b * b - 4 * a * c;
            if (D >= 0)
            {
                X1     = (-1 * b + Math.Sqrt(D)) / (2 * a);
                X2     = (-1 * b - Math.Sqrt(D)) / (2 * a);
                res[0] = X1.ToString("F4");
                res[1] = X2.ToString("F4");
                return(res);
            }
            else
            {
                res[0] = (-1 * b / (2 * a)).ToString("F4") + "+" +
                         (Math.Sqrt(-1 * D) / (2 * a)).ToString("F4") + "i";
                res[1] = (-1 * b / (2 * a)).ToString("F4") + "-" +
                         (Math.Sqrt(-1 * D) / (2 * a)).ToString("F4") + "i";
                return(res);
            }
        }
Esempio n. 24
0
        static void Main(string[] args)
        {
            double A, B, C, X1, X2, Delta;

            string[] vet = Console.ReadLine().Split(' ');
            A     = double.Parse(vet [0], CultureInfo.InvariantCulture);
            B     = double.Parse(vet[1], CultureInfo.InvariantCulture);
            C     = double.Parse(vet[2], CultureInfo.InvariantCulture);
            Delta = Math.Pow(B, 2.0) - (4 * A * C);
            X1    = (-(B) + Math.Sqrt(Delta)) / (2.0 * A);
            X2    = (-(B)-Math.Sqrt(Delta)) / (2.0 * A);


            if (Delta < 0 || A == 0)
            {
                Console.WriteLine("Impossivel calcular");
            }
            else
            {
                Console.WriteLine("R1 = " + X1.ToString("F5", CultureInfo.InvariantCulture));
                Console.WriteLine("R2 = " + X2.ToString("F5", CultureInfo.InvariantCulture));
            }
        }
Esempio n. 25
0
        private void buttonAns_Click(object sender, EventArgs e)
        {
            double a, b, c, X1, X2;

            a = double.Parse(textBoxA.Text);
            b = double.Parse(textBoxB.Text);
            c = double.Parse(textBoxC.Text);
            try
            {
                X1 = -b + Math.Sqrt((Math.Pow(b, 2)) - (4 * a * c));
                X1 = X1 / (2 * a);
                X2 = -b - Math.Sqrt((Math.Pow(b, 2)) - (4 * a * c));
                X2 = X2 / (2 * a);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                X1 = 0.0;
                X2 = 0.0;
            }
            labelAns1.Text = X1.ToString();
            labelAns2.Text = X2.ToString();
        }
Esempio n. 26
0
        // Tab number 2 (   Equation    )
        private void buttonAns_Click(object sender, EventArgs e)
        {
            float a, b, c, X1, X2;

            a = float.Parse(textBoxA.Text);
            b = float.Parse(textBoxB.Text);
            c = float.Parse(textBoxC.Text);
            try
            {
                X1 = -b + (float)Math.Sqrt((Math.Pow(b, 2)) - (4 * a * c));  //Math.Pow retuen double
                X1 = X1 / (2 * a);
                X2 = -b - (float)Math.Sqrt((Math.Pow(b, 2)) - (4 * a * c));
                X2 = X2 / (2 * a);
            }
            catch (Exception ex) // for when there is a problem in X1 and X2, label would shpw X1=X2=0
            {
                MessageBox.Show(ex.Message.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                X1 = 0;
                X2 = 0;
            }
            labelAns1.Text = X1.ToString();
            labelAns2.Text = X2.ToString();
        }
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            if (questions.SelectedIndex == 0)
            {
                if (txtA.Text == "" && txtB.Text == "")
                {
                    txtA.Text = "0.2";
                    txtB.Text = "0.3";
                    int row = dataGridView1.Rows.Count;
                    if (row > 0)
                    {
                        table.Rows.Clear();
                    }

                    X0 = Convert.ToDouble(txtA.Text);
                    X1 = Convert.ToDouble(txtB.Text);

                    Xn1   = Convert.ToDouble(string.Format("{0:0.000}", X1 - ((ques.secant1(X1) * (X1 - X0)) / (ques.secant1(X1) - (ques.secant1(X0))))));
                    error = Math.Abs(Xn1 - X1);

                    for (int i = 0; i < 50; i++)
                    {
                        if (string.Format("{0:0.000}", error) != string.Format("{0:0.000}", 0.000))
                        {
                            if (i != 0)
                            {
                                X0  = X1;
                                X1  = Xn1;
                                Xn1 = Convert.ToDouble(string.Format("{0:0.000}", X1 - ((ques.secant1(X1) * (X1 - X0)) / (ques.secant1(X1) - (ques.secant1(X0))))));

                                error = Math.Abs(Xn1 - X1);
                            }


                            table.Rows.Add((i + 1).ToString(), string.Format("{0:0.000}", X0), string.Format("{0:0.000}", X1), string.Format("{0:0.000}", ques.secant1(X0)), string.Format("{0:0.000}", ques.secant1(X1)), Xn1.ToString(), string.Format("{0:0.000}", error));
                        }
                        else
                        {
                            break;
                        }
                    }
                }
                else
                {
                    int row = dataGridView1.Rows.Count;
                    if (row > 0)
                    {
                        table.Rows.Clear();
                    }

                    X0 = Convert.ToDouble(txtA.Text);
                    X1 = Convert.ToDouble(txtB.Text);


                    Xn1   = Convert.ToDouble(string.Format("{0:0.000}", X1 - ((ques.secant1(X1) * (X1 - X0)) / (ques.secant1(X1) - (ques.secant1(X0))))));
                    error = Math.Abs(Xn1 - X1);

                    for (int i = 0; i < 50; i++)
                    {
                        if (string.Format("{0:0.000}", error) != string.Format("{0:0.000}", 0.000))
                        {
                            if (i != 0)
                            {
                                X0  = X1;
                                X1  = Xn1;
                                Xn1 = Convert.ToDouble(string.Format("{0:0.000}", X1 - ((ques.secant1(X1) * (X1 - X0)) / (ques.secant1(X1) - (ques.secant1(X0))))));

                                error = Math.Abs(Xn1 - X1);
                            }


                            table.Rows.Add((i + 1).ToString(), string.Format("{0:0.000}", X0), string.Format("{0:0.000}", X1), string.Format("{0:0.000}", ques.secant1(X0)), string.Format("{0:0.000}", ques.secant1(X1)), Xn1.ToString(), string.Format("{0:0.000}", error));
                        }
                        else
                        {
                            break;
                        }
                    }
                }
            }
            else if (questions.SelectedIndex == 1)
            {
                if (txtA.Text == "" && txtB.Text == "")
                {
                    txtA.Text = "1.2";
                    txtB.Text = "1.3";
                    int row = dataGridView1.Rows.Count;
                    if (row > 0)
                    {
                        table.Rows.Clear();
                    }

                    X0 = Convert.ToDouble(txtA.Text);
                    X1 = Convert.ToDouble(txtB.Text);

                    MessageBox.Show(X0.ToString());

                    MessageBox.Show(X1.ToString());
                    Xn1   = Convert.ToDouble(string.Format("{0:0.000}", X1 - ((ques.secant2(X1) * (X1 - X0)) / (ques.secant2(X1) - (ques.secant2(X0))))));
                    error = Math.Abs(Xn1 - X1);

                    for (int i = 0; i < 50; i++)
                    {
                        if (string.Format("{0:0.000}", error) != string.Format("{0:0.000}", 0.000))
                        {
                            if (i != 0)
                            {
                                X0  = X1;
                                X1  = Xn1;
                                Xn1 = Convert.ToDouble(string.Format("{0:0.000}", X1 - ((ques.secant2(X1) * (X1 - X0)) / (ques.secant2(X1) - (ques.secant2(X0))))));

                                error = Math.Abs(Xn1 - X1);
                            }


                            table.Rows.Add((i + 1).ToString(), string.Format("{0:0.000}", X0), string.Format("{0:0.000}", X1), string.Format("{0:0.000}", ques.secant3(X0)), string.Format("{0:0.000}", ques.secant3(X1)), Xn1.ToString(), string.Format("{0:0.000}", error));
                        }
                        else
                        {
                            break;
                        }
                    }
                }
                else
                {
                    int row = dataGridView1.Rows.Count;
                    if (row > 0)
                    {
                        table.Rows.Clear();
                    }

                    X0 = Convert.ToDouble(txtA.Text);
                    X1 = Convert.ToDouble(txtB.Text);

                    MessageBox.Show(X0.ToString());

                    MessageBox.Show(X1.ToString());
                    Xn1   = Convert.ToDouble(string.Format("{0:0.000}", X1 - ((ques.secant2(X1) * (X1 - X0)) / (ques.secant2(X1) - (ques.secant2(X0))))));
                    error = Math.Abs(Xn1 - X1);

                    for (int i = 0; i < 50; i++)
                    {
                        if (string.Format("{0:0.000}", error) != string.Format("{0:0.000}", 0.000))
                        {
                            if (i != 0)
                            {
                                X0  = X1;
                                X1  = Xn1;
                                Xn1 = Convert.ToDouble(string.Format("{0:0.000}", X1 - ((ques.secant2(X1) * (X1 - X0)) / (ques.secant2(X1) - (ques.secant2(X0))))));

                                error = Math.Abs(Xn1 - X1);
                            }


                            table.Rows.Add((i + 1).ToString(), string.Format("{0:0.000}", X0), string.Format("{0:0.000}", X1), string.Format("{0:0.000}", ques.secant3(X0)), string.Format("{0:0.000}", ques.secant3(X1)), Xn1.ToString(), string.Format("{0:0.000}", error));
                        }
                        else
                        {
                            break;
                        }
                    }
                }
            }
            else if (questions.SelectedIndex == 2)
            {
                if (txtA.Text == "" && txtB.Text == "")
                {
                    txtA.Text = "0.2";
                    txtB.Text = "0.3";
                    int row = dataGridView1.Rows.Count;
                    if (row > 0)
                    {
                        table.Rows.Clear();
                    }

                    X0 = Convert.ToDouble(txtA.Text);
                    X1 = Convert.ToDouble(txtB.Text);

                    MessageBox.Show(X0.ToString());

                    MessageBox.Show(X1.ToString());
                    Xn1   = Convert.ToDouble(string.Format("{0:0.000}", X1 - ((ques.secant3(X1) * (X1 - X0)) / (ques.secant3(X1) - (ques.secant3(X0))))));
                    error = Math.Abs(Xn1 - X1);

                    for (int i = 0; i < 50; i++)
                    {
                        if (string.Format("{0:0.000}", error) != string.Format("{0:0.000}", 0.000))
                        {
                            if (i != 0)
                            {
                                X0  = X1;
                                X1  = Xn1;
                                Xn1 = Convert.ToDouble(string.Format("{0:0.000}", X1 - ((ques.secant3(X1) * (X1 - X0)) / (ques.secant3(X1) - (ques.secant3(X0))))));

                                error = Math.Abs(Xn1 - X1);
                            }


                            table.Rows.Add((i + 1).ToString(), string.Format("{0:0.000}", X0), string.Format("{0:0.000}", X1), string.Format("{0:0.000}", ques.secant3(X0)), string.Format("{0:0.000}", ques.secant3(X1)), Xn1.ToString(), string.Format("{0:0.000}", error));
                        }
                        else
                        {
                            break;
                        }
                    }
                }
                else
                {
                    int row = dataGridView1.Rows.Count;
                    if (row > 0)
                    {
                        table.Rows.Clear();
                    }

                    X0 = Convert.ToDouble(txtA.Text);
                    X1 = Convert.ToDouble(txtB.Text);

                    MessageBox.Show(X0.ToString());

                    MessageBox.Show(X1.ToString());
                    Xn1   = Convert.ToDouble(string.Format("{0:0.000}", X1 - ((ques.secant3(X1) * (X1 - X0)) / (ques.secant3(X1) - (ques.secant3(X0))))));
                    error = Math.Abs(Xn1 - X1);

                    for (int i = 0; i < 50; i++)
                    {
                        if (string.Format("{0:0.000}", error) != string.Format("{0:0.000}", 0.000))
                        {
                            if (i != 0)
                            {
                                X0  = X1;
                                X1  = Xn1;
                                Xn1 = Convert.ToDouble(string.Format("{0:0.000}", X1 - ((ques.secant3(X1) * (X1 - X0)) / (ques.secant3(X1) - (ques.secant3(X0))))));

                                error = Math.Abs(Xn1 - X1);
                            }


                            table.Rows.Add((i + 1).ToString(), string.Format("{0:0.000}", X0), string.Format("{0:0.000}", X1), string.Format("{0:0.000}", ques.secant3(X0)), string.Format("{0:0.000}", ques.secant3(X1)), Xn1.ToString(), string.Format("{0:0.000}", error));
                        }
                        else
                        {
                            break;
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("Select Question First", "Question Error", MessageBoxButtons.OKCancel);
            }
        }
Esempio n. 28
0
 public string ToString(string format, IFormatProvider provider)
 {
     return($"X1={X1.ToString(format, provider)} Y1={Y1.ToString(format, provider)} X2={X2.ToString(format, provider)} Y2={Y2.ToString(format, provider)}");
 }
 /// <summary>
 /// Returns the CSS representation of the cubic bezier timing function.
 /// </summary>
 /// <returns>A string that resembles CSS code.</returns>
 public override String ToCss()
 {
     return FunctionNames.Build(FunctionNames.CubicBezier, 
         X1.ToString(CultureInfo.InvariantCulture), Y1.ToString(CultureInfo.InvariantCulture), 
         X2.ToString(CultureInfo.InvariantCulture), Y2.ToString(CultureInfo.InvariantCulture));
 }
Esempio n. 30
0
 public override string ToString()
 {
     return(base.ToString() + "X1=" + X1.ToString() + ";Y1=" + Y1.ToString());
 }