Ejemplo n.º 1
0
        private GraphLine FormLine(double h, double[] t)
        {
            PointF[] points = new PointF[t.Length];
            for (int i = 0; i < points.Length; i++)
            {
                points[i].X = (float)(i * h);
                points[i].Y = (float)t[i];
            }

            GraphLine gl = new GraphLine();

            gl.Nodes = points;
            gl.Color = Color.Red;

            return(gl);
        }
Ejemplo n.º 2
0
        public void DrawLine(GraphLine line, float xMin, float xMax, float yMin, float yMax)
        {
            PointF previousPoint = line.Nodes[0];
            Pen    p             = new Pen(line.Color);

            PointF ScaledPoint(PointF point)
            {
                float x = SPACE_LEFT + point.X * WIDTH / (xMax - xMin);
                float y = HEIGHT - point.Y * HEIGHT / (yMax - yMin);

                return(new PointF(x, y));
            }

            for (int i = 1; i < line.Nodes.Length; i++)
            {
                graphics.DrawLine(p, ScaledPoint(line.Nodes[i - 1]), ScaledPoint(line.Nodes[i]));
            }
        }
Ejemplo n.º 3
0
        private void btnSolve_Click(object sender, EventArgs e)
        {
            try
            {
                double L    = double.Parse(tbL.Text);
                double R    = double.Parse(tbR.Text);
                double Tenv = double.Parse(tbTenv.Text);
                double F0   = double.Parse(tbF0.Text);
                double K0   = double.Parse(tbK0.Text);
                double Kn   = double.Parse(tbKn.Text);
                double A0   = double.Parse(tbA0.Text);
                double An   = double.Parse(tbAn.Text);
                int    N    = int.Parse(tbN.Text);

                Task1     task = new Task1(L, R, Tenv, F0, K0, Kn, A0, An, N);
                GraphLine gl   = task.FindSolution();

                /*Task2 task = new Task2(L, R, Tenv, F0, K0, Kn, A0, An, N);
                 * GraphLine gl;
                 * Mathematics.FunNode2[] t = task.FindSolution();
                 * gl.Color = Color.Red;
                 * gl.Nodes = new PointF[N + 1];
                 *
                 * for (int i = 0; i <= N; i++)
                 * {
                 *  gl.Nodes[i] = (PointF)t[i];
                 * }*/

                Graph graph = new Graph(pbGraph.Width, pbGraph.Height);
                graph.Draw(new GraphLine[] { gl }, 0, (float)L, 0,
                           Math.Max(gl.Nodes[0].Y, gl.Nodes[N].Y));

                pbGraph.CreateGraphics().DrawImage(graph.Image, 0, 0);
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
        }