Ejemplo n.º 1
0
Archivo: Form1.cs Proyecto: a-27m/vssdb
        void solver_DebugMaxMin(FractionPoint max, FractionPoint min, Fraction f_tan)
        {
            if (df == null)
            {
                df      = new DekartForm(100, 100, 100, 100);
                df.Text = "max & min";
            }

            df.Use_IsVisible = false;

            // n
            df.AddPolygon(Color.Black, DrawModes.DrawLines,
                          new PointF(1000, f_tan * 1000),
                          new PointF(-1000, -f_tan * 1000));

            for (float percent = 0; ; percent += .05f)
            {
                int id1 = df.AddPolygon(Color.Black, DrawModes.DrawLines,
                                        new PointF(1000 + max.X * percent, -1 / f_tan * 1000 + max.Y * percent),
                                        new PointF(-1000 + max.X * percent, 1 / f_tan * 1000 + max.Y * percent));
                int id2 = df.AddPolygon(Color.Black, DrawModes.DrawLines,
                                        new PointF(1000 + min.X * percent, -1 / f_tan * 1000 + min.Y * percent),
                                        new PointF(-1000 + min.X * percent, 1 / f_tan * 1000 + min.Y * percent));
                //int id1 = df.AddPolygon(Color.Orange, DrawModes.DrawLines,
                //       new PointF(1000 + max.X * percent, -1 / f_tan * 1000 + max.Y * percent),
                //       new PointF(-1000 + max.X * percent, 1 / f_tan * 1000 + max.Y * percent));
                //int id2 = df.AddPolygon(Color.CornflowerBlue, DrawModes.DrawLines,
                //    new PointF(1000 + min.X * percent, -1 / f_tan * 1000 + min.Y * percent),
                //    new PointF(-1000 + min.X * percent, 1 / f_tan * 1000 + min.Y * percent));
                if (percent >= 0.99f)
                {
                    break;
                }
                df.Update2();
                Application.DoEvents();
                df.RemoveGraphic(id2);
                df.RemoveGraphic(id1);
            }

            //df.AddPolygon(Color.Orange, 3f, DrawModes.DrawPoints, new PointF(max.X, max.Y));
            //df.AddPolygon(Color.CornflowerBlue, 3f, DrawModes.DrawPoints, new PointF(min.X, min.Y));

            df.AddPolygon(Color.Black, 3f, DrawModes.DrawPoints, new PointF(max.X, max.Y));
            df.AddPolygon(Color.Black, 3f, DrawModes.DrawPoints, new PointF(min.X, min.Y));

            df.Show();
            df.Update2();
        }
Ejemplo n.º 2
0
Archivo: Form4.cs Proyecto: a-27m/vssdb
        private void RunWave_Click(object sender, EventArgs e)
        {
            DekartForm dForm = new DekartForm(150, 150, 50, 175);

            dForm.Size = new Size(800, 420);
            dForm.Text = "f(x,t) = |cos(t)|*sin(4x)";

            dForm.Show();

            int tmpID = -1;

            for (t = 0; !dForm.IsDisposed; t += 0.1f)
            {
                if (t > +2 * Math.PI)
                {
                    t -= 2 * (float)Math.PI;
                }

                if (tmpID >= 0)
                {
                    dForm.RemoveGraphic(tmpID);
                }
                tmpID = dForm.AddGraphic(fun, -5, 5,
                                         DrawModes.DrawLines, Color.Red);

                dForm.Update2();                //.DrawAllGraphics();
                Application.DoEvents();
            }
        }
Ejemplo n.º 3
0
Archivo: Form4.cs Proyecto: a-27m/vssdb
        private void RollStar_Click(object sender, EventArgs e)
        {
            DekartForm dForm = new DekartForm(150, 150, 180, 175);

            dForm.Use_IsVisible = false;
            dForm.Size          = new Size(400, 425);
            dForm.Text          = "f(x) = 5sin(x^3)-x";
            dForm.Show();

            int    k      = 7;
            int    tmpID  = -1;
            int    grnVal = 150;
            int    grnDx  = 1;
            Random rnd    = new Random((int)(DateTime.Now.Ticks));

            for (float phi = -0.01f; !dForm.IsDisposed;
                 //phi += phi/5 )  //for !crazy!
                 phi += -0.008f)                 //normal
            {
                grnVal += ((grnVal < 100) || (grnVal > 200))
                                        ? grnDx *= -1 : grnDx;

                if (phi < -2 * Math.PI)
                {
                    phi += 2 * (float)Math.PI;
                }

                int      l   = 0;
                PointF[] pts = new PointF[k * k];
                float    r   = 0.5f * (float)Math.Abs(Math.Cos(3 * phi)) + 0.5f;
                //Math.Abs(Math.Cos(t) + 0.5);
                for (int i = 0; i < k; i++)
                {
                    PointF pti = new PointF(
                        r * (float)Math.Cos(2 * i * Math.PI / k + phi),
                        r * (float)Math.Sin(2 * i * Math.PI / k + phi));
                    for (int j = 0; j < i; j++)
                    {
                        if ((j == i - 1) ||
                            (j == 0 && i == k - 1))
                        {
                            continue;
                        }
                        pts[l++] = pti;
                        pts[l++] = new PointF(
                            r * (float)Math.Cos(2 * j * Math.PI / k + phi),
                            r * (float)Math.Sin(2 * j * Math.PI / k + phi)
                            );
                    }
                }

                Array.Resize <PointF>(ref pts, l);

                Color cl = Color.FromArgb(100, grnVal, 100);

                if (tmpID >= 0)
                {
                    dForm.RemoveGraphic(tmpID);
                }

                tmpID = dForm.AddPolygon(cl, 2f, DrawModes.DrawLines, pts);
                dForm.Update2();
                //.DrawAllGraphics();
                Application.DoEvents();
            }
        }
Ejemplo n.º 4
0
        void dfSFPriodic_dfClosed(object sender, EventArgs e)
        {
            float oneThird = 1f / 3f;

            if (ActiveMdiChild is FormChild)
            {
                FormChild activeMdiChild = ActiveMdiChild as FormChild;

                double[] data = activeMdiChild.DataAsRow;

                DekartForm df = dform;

                PointF[] pts;

                if (!clickSentinels.Contains(data.Length - 1))
                {
                    clickSentinels.Add(data.Length - 1);
                }
                double[] m = new double[clickSentinels.Count];
                clickSentinels.Sort();

                if (grIds == null)
                {
                    grIds = new List <int>(100);
                }
                else
                {
                    try
                    {
                        for (int i = 0; i < grIds.Count; i++)
                        {
                            df.RemoveGraphic(grIds[i]);

                            for (int l = 0; l < grIds.Count; l++)
                            {
                                if (grIds[l] > grIds[i])
                                {
                                    grIds[l]--;
                                }
                            }
                        }
                    }
                    catch (ArgumentOutOfRangeException) { }

                    grIds.Clear();
                }

                int first = 0;
                for (int i = 0; i < clickSentinels.Count; i++)
                {
                    pts = new PointF[2];
                    for (int k = first; k <= clickSentinels[i]; k++)
                    {
                        m[i] += data[k];
                    }
                    m[i] /= clickSentinels[i] - first + 1;

                    pts[0].X = first - oneThird;
                    pts[1].X = clickSentinels[i] + oneThird;
                    pts[0].Y = pts[1].Y = (float)m[i];

                    grIds.Add(df.AddPolygon(Color.Red, 2f, DrawModes.DrawLines, pts));

                    first = clickSentinels[i] + 1;
                }

                //pts = new PointF[data.Length];
                //for (int i = 0; i < data.Length; i++)
                //{
                //    pts[i].X = i;
                //    pts[i].Y = (float)data[i];
                //}
                //df.AddPolygon(Color.Green, 3f, DrawModes.DrawPoints, pts);

                df.Use_IsVisible = false;
                df.Show();
                df.Update2();
            }
        }