Exemplo n.º 1
0
 public Plot2D(string function_VBSYNTAX, Plot2DSettings S)
 {
     settings = S;
     throw new Exception("Error: Function not yet implemented");
     canvas        = new Bitmap(S.ImageWidth, S.ImageHeight);
     x_pixel_count = canvas.Width;
     y_pixel_count = canvas.Height;
     get_positions();
 }
Exemplo n.º 2
0
        public Plot2D(double[] x, double[] y, Plot2DSettings S)
        {
            settings = S;
            if (x.Length != y.Length)
            {
                throw new Exception("Error: Array dimensions are inconsistent.");
            }
            xvals         = x;
            yvals         = y;
            canvas        = new Bitmap(S.ImageWidth, S.ImageHeight);
            x_pixel_count = canvas.Width;
            y_pixel_count = canvas.Height;
            double ymax = double.NegativeInfinity;
            double ymin = double.PositiveInfinity;
            double xmax = double.NegativeInfinity;
            double xmin = double.PositiveInfinity;

            for (int i = 0; i < x.Length; i++)
            {
                if (x[i] > xmax)
                {
                    xmax = x[i];
                }
                if (x[i] < xmin)
                {
                    xmin = x[i];
                }
                if (y[i] > ymax)
                {
                    ymax = y[i];
                }
                if (y[i] < ymin)
                {
                    ymin = y[i];
                }
            }
            double deltax    = xmax - xmin;
            double deltay    = ymax - ymin;
            double xbar      = (xmax + xmin) * 0.5;
            double ybar      = (ymax + ymin) * 0.5;
            double xscl      = 1.0;
            double yscl      = 1.0;
            double newdeltax = xscl * deltax;
            double newdeltay = yscl * deltay;

            xmax          = xbar + 0.5 * newdeltax;
            xmin          = xbar - 0.5 * newdeltax;
            ymax          = ybar + 0.5 * newdeltay;
            ymin          = ybar - 0.5 * newdeltay;
            sketch_bounds = new RBounds2D(xmin, xmax, ymin, ymax);
            get_positions();
        }
Exemplo n.º 3
0
        public static Plot2D ReadCSV(string path, Plot2DSettings S, params int[] yindeces)
        {
            string[] filestuff  = File.ReadAllLines(path);
            int      stuffcount = filestuff[0].Split(',').Length - 1;

            int[] index = yindeces;
            if (yindeces.Length == 0)
            {
                index = new int[stuffcount];
                for (int i = 0; i < stuffcount; i++)
                {
                    index[i] = i + 1;
                }
            }
            List <double>[] arrs = new List <double> [index.Length + 1];
            for (int i = 0; i < arrs.Length; i++)
            {
                arrs[i] = new List <double>();
            }
            for (int i = 0; i < filestuff.Length; i++)
            {
                string[]      spt       = filestuff[i].Split(',');
                double        x         = Convert.ToDouble(spt[0]);
                List <double> curdouble = new List <double>();
                foreach (int f in index)
                {
                    curdouble.Add(Convert.ToDouble(spt[f]));
                }
                arrs[0].Add(x);
                for (int q = 1; q <= curdouble.Count; q++)
                {
                    arrs[q].Add(curdouble[q - 1]);
                }
            }
            double[] basex = arrs[0].ToArray();
            double[] basey = arrs[1].ToArray();
            Plot2D   plot  = new Plot2D(basex, basey, S);

            for (int i = 2; i < arrs.Length; i++)
            {
                plot.AddCurve(basex, arrs[i].ToArray(), default_colors[i - 2]);
            }
            return(plot);
        }
Exemplo n.º 4
0
 public void SetSketchSettings(Plot2DSettings S)
 {
     settings = S;
     get_positions();
 }