Exemplo n.º 1
0
        public static void Mandelbrot(PlotControl plot)
        {
            // Here we add the Mandelbrot set to the plot.

            Function2DItem m = new Function2DItem(
                // The source represents the body of the following function:
                // double[] p, dfdp;
                // double f(double x, double y) {
                //   ...
                // }
                @"
					double xn = 0, yn = 0, x2 = 0, y2 = 0;
					for (int n = 0; n < 500; n++) {
						yn = 2*xn*yn + y;
						xn = x2 - y2 + x;
						x2 = xn*xn; y2 = yn*yn; 
						if (x2 + y2 > 4) return n;
					}
					return -1;
				"                );

            plot.Model.FixXtoY = true;             // We fix the x-plotrange to the y-plotrange, so the
            // proportions of the plot will be correct.
            plot.SetRange(plot.x0, plot.x1, plot.y0, plot.y1, 0, 20);
            // We set the view range of the plot, so the Mandelbrot set will be
            // fully visible. We set the z-plotrange from 0 to 20.
            plot.Model.Add(m);
        }
Exemplo n.º 2
0
        public static void WAV(PlotControl plot)
        {
            DataItem data = new DataItem();

            data.Lines        = true;       // join data points with a line
            data.Marks        = false;      // draw no error marks
            data.Color        = Color.Green;
            data.Dimensions   = 2;          // use x and y columns of the DataItem
            data.ErrorColumns = false;      // WAV data contains no error info
            try {
                // Load WAV data
                data.LoadWAV("test.wav");
            } catch (Exception ex) {
                MessageBox.Show("Could not open the file test.wav\n" + ex.Message);
            }
            plot.SetRange(0, 1, -1, 1);
            plot.Model.Add(data);
        }
Exemplo n.º 3
0
        private void Apply()
        {
            try {
                double x0 = double.Parse(x0TextBox.Text);
                double y0 = double.Parse(y0TextBox.Text);
                double x1 = double.Parse(x1TextBox.Text);
                double y1 = double.Parse(y1TextBox.Text);
                double z0 = double.Parse(z0TextBox.Text);
                double z1 = double.Parse(z1TextBox.Text);

                plot.Model.FixXtoY = fixytox.Checked;
                plot.Model.xLog    = xlog.Checked; plot.Model.yLog = ylog.Checked; plot.Model.zLog = zlog.Checked;
                plot.SetRange(x0, x1, y0, y1, z0, z1);
                Reset();
            } catch {
                DialogResult res = MessageBox.Show("One of the entered numbers is invalid.");
                throw new System.ApplicationException();
            }
        }
Exemplo n.º 4
0
 private void clearClick(object sender, EventArgs e)
 {
     plot.Model.Clear();
     plot.SetRange(-8, 4, -4, 4);
 }