Example #1
0
        public static Plot2D operator +(PPoint2D a, PPoint2D b)
        {
            Plot2D   plot2D = new Plot2D();
            PPoint2D p1     = a;

            plot2D.AddPoint(p1);
            PPoint2D p2 = b;

            plot2D.AddPoint(p2);
            return(plot2D);
        }
Example #2
0
        public static Plot2D ReuleauxPolygonF(float dx, int n, float scale, Color color)
        {
            Plot2D plot2D = new Plot2D();
            var    num1   = 0.0f;

            while (num1 <= 2.0 * Math.PI)
            {
                var num2 =
                    (float)
                    (2.0 * Math.Cos(Math.PI / (2 * n)) *
                     Math.Cos(0.5 * (num1 + Math.PI / n * (2.0 * Math.Floor(n * (double)num1 / (2.0 * Math.PI)) + 1.0))) -
                     Math.Cos(Math.PI / n * (2.0 * Math.Floor(n * (double)num1 / (2.0 * Math.PI)) + 1.0)));
                var num3 =
                    (float)
                    (2.0 * Math.Cos(Math.PI / (2 * n)) *
                     Math.Sin(0.5 * (num1 + Math.PI / n * (2.0 * Math.Floor(n * (double)num1 / (2.0 * Math.PI)) + 1.0))) -
                     Math.Sin(Math.PI / n * (2.0 * Math.Floor(n * (double)num1 / (2.0 * Math.PI)) + 1.0)));
                var num4 = (float)Math.Sqrt(num2 * (double)num2 + num3 * (double)num3);
                var num5 = num2 / num4;
                var num6 = num3 / num4;
                var num7 = num4 * scale;
                var num8 = dx;
                while (num8 <= (double)num7)
                {
                    plot2D.AddPoint(new PPoint2D(num5 * num8, num6 * num8, color));
                    num8 += dx;
                }
                num1 += dx;
            }
            return(plot2D);
        }
Example #3
0
        public static Plot2D Rectangle(float dx, float a, float b, Color color)
        {
            Plot2D plot2D = new Plot2D();
            var    x      = 0.0f;

            while (x <= (double)a)
            {
                plot2D.AddPoint(new PPoint2D(x, 0.0f, color));
                plot2D.AddPoint(new PPoint2D(x, b, color));
                x += dx;
            }
            var y = 0.0f;

            while (y <= (double)b)
            {
                plot2D.AddPoint(new PPoint2D(0.0f, y, color));
                plot2D.AddPoint(new PPoint2D(a, y, color));
                y += dx;
            }
            return(plot2D);
        }
Example #4
0
        public static Plot2D Ellipse(float dx, float a, float b, Color color)
        {
            Plot2D plot2D = new Plot2D();
            var    num    = 0.0f;

            while (num <= 2.0 * Math.PI)
            {
                plot2D.AddPoint(new PPoint2D((float)Math.Cos(num) * a, (float)Math.Sin(num) * b, color));
                num += dx;
            }
            return(plot2D);
        }
Example #5
0
        public static Plot2D Line2D(float dx, PPoint2D a, PPoint2D b, Color color)
        {
            Plot2D plot2D = new Plot2D();
            var    num1   = a.X - b.X;
            var    num2   = a.Y - b.Y;
            var    num3   = (float)Math.Sqrt(num1 * (double)num1 + num2 * (double)num2);
            var    num4   = num1 / num3;
            var    num5   = num2 / num3;
            var    num6   = 0.0f;

            while (num6 <= (double)num3)
            {
                plot2D.AddPoint(new PPoint2D(num6 * num4 + b.X, num6 * num5 + b.Y, color));
                num6 += dx;
            }
            return(plot2D);
        }
Example #6
0
        public static Plot2D CircleF(float dx, float r, Color color)
        {
            Plot2D plot2D = new Plot2D();
            var    num1   = 0.0f;

            while (num1 <= 2.0 * Math.PI)
            {
                var num2 = (float)Math.Cos(num1);
                var num3 = (float)Math.Sin(num1);
                var num4 = dx;
                while (num4 <= (double)r)
                {
                    plot2D.AddPoint(new PPoint2D(num2 * num4, num3 * num4, color));
                    num4 += dx;
                }
                num1 += dx;
            }
            return(plot2D);
        }
Example #7
0
        public static Plot2D ReuleauxPolygon(float dx, int n, float scale, Color color)
        {
            Plot2D plot2D = new Plot2D();
            var    num1   = 0.0f;

            while (num1 <= 2.0 * Math.PI)
            {
                var num2 =
                    (float)
                    (2.0 * Math.Cos(Math.PI / (2 * n)) *
                     Math.Cos(0.5 * (num1 + Math.PI / n * (2.0 * Math.Floor(n * (double)num1 / (2.0 * Math.PI)) + 1.0))) -
                     Math.Cos(Math.PI / n * (2.0 * Math.Floor(n * (double)num1 / (2.0 * Math.PI)) + 1.0)));
                var num3 =
                    (float)
                    (2.0 * Math.Cos(Math.PI / (2 * n)) *
                     Math.Sin(0.5 * (num1 + Math.PI / n * (2.0 * Math.Floor(n * (double)num1 / (2.0 * Math.PI)) + 1.0))) -
                     Math.Sin(Math.PI / n * (2.0 * Math.Floor(n * (double)num1 / (2.0 * Math.PI)) + 1.0)));
                plot2D.AddPoint(new PPoint2D(num2 * scale, num3 * scale, color));
                num1 += dx;
            }
            return(plot2D);
        }
Example #8
0
        public static Plot2D EllipseF(float dx, float a, float b, Color color)
        {
            Plot2D plot2D = new Plot2D();
            var    num1   = 0.0f;

            while (num1 <= 2.0 * Math.PI)
            {
                var num2 = (float)Math.Cos(num1) * a;
                var num3 = (float)Math.Sin(num1) * b;
                var num4 = (float)Math.Sqrt(num2 * (double)num2 + num3 * (double)num3);
                var num5 = num2 / num4;
                var num6 = num3 / num4;
                var num7 = dx;
                while (num7 <= (double)num4)
                {
                    plot2D.AddPoint(new PPoint2D(num5 * num7, num6 * num7, color));
                    num7 += dx;
                }
                num1 += dx;
            }
            return(plot2D);
        }
Example #9
0
 private static void PlotP(Onp o, Queue <string> fX, Queue <string> fY, IReadOnlyList <char> vars,
                           IReadOnlyList <Range> ranges, Plot2D p, Dictionary <char, double> d, int a, Color color)
 {
     if (a >= vars.Count - 1)
     {
         var num = ranges[a].Min;
         while (num <= (double)ranges[a].Max)
         {
             d[vars[a]] = num;
             p.AddPoint(new PPoint2D((float)o.Solve(fX, d), (float)o.Solve(fY, d), color));
             num += ranges[a].Diff;
         }
     }
     else
     {
         var num = ranges[a].Min;
         while (num <= (double)ranges[a].Max)
         {
             d[vars[a]] = num;
             PlotP(o, fX, fY, vars, ranges, p, d, a + 1, color);
             num += ranges[a].Diff;
         }
     }
 }