コード例 #1
0
ファイル: VectorField.cs プロジェクト: Jmerk523/ScottPlot
        public void ExecuteRecipe(Plot plt)
        {
            double[] xPositions = DataGen.Range(0, 10);
            double[] yPositions = DataGen.Range(0, 10);
            Vector2[,] vectors = new Vector2[xPositions.Length, yPositions.Length];

            for (int x = 0; x < xPositions.Length; x++)
            {
                for (int y = 0; y < yPositions.Length; y++)
                {
                    vectors[x, y] = new Vector2(
                        x: Math.Sin(xPositions[x]),
                        y: Math.Sin(yPositions[y]));
                }
            }

            plt.AddVectorField(vectors, xPositions, yPositions);
        }
コード例 #2
0
        public void ExecuteRecipe(Plot plt)
        {
            // create an interesting plot
            double[] xs = DataGen.Range(-5, 5, .5);
            double[] ys = DataGen.Range(-5, 5, .5);
            Vector2[,] vectors = new Vector2[xs.Length, ys.Length];
            for (int i = 0; i < xs.Length; i++)
            {
                for (int j = 0; j < ys.Length; j++)
                {
                    vectors[i, j] = new Vector2(ys[j], -15 * Math.Sin(xs[i]));
                }
            }
            plt.AddVectorField(vectors, xs, ys, colormap: Drawing.Colormap.Turbo);

            // use images as axis labels
            plt.XAxis.ImageLabel(new Bitmap("Images/theta.png"));
            plt.YAxis.ImageLabel(new Bitmap("Images/d_theta_dt.png"));
        }
コード例 #3
0
ファイル: VectorField.cs プロジェクト: Jmerk523/ScottPlot
        public void ExecuteRecipe(Plot plt)
        {
            double[] xs = DataGen.Range(-5, 6);
            double[] ys = DataGen.Range(-5, 6);
            Vector2[,] vectors = new Vector2[xs.Length, ys.Length];

            for (int i = 0; i < xs.Length; i++)
            {
                for (int j = 0; j < ys.Length; j++)
                {
                    double slope     = -xs[i];
                    double magnitude = Math.Abs(xs[i]);
                    double angle     = Math.Atan(slope);

                    vectors[i, j] = new Vector2(Math.Cos(angle) * magnitude, Math.Sin(angle) * magnitude);
                }
            }

            plt.AddVectorField(vectors, xs, ys);
        }
コード例 #4
0
ファイル: VectorField.cs プロジェクト: Jmerk523/ScottPlot
        public void ExecuteRecipe(Plot plt)
        {
            double[] xPositions = DataGen.Range(0, 10);
            double[] yPositions = DataGen.Range(0, 10);
            Vector2[,] vectors = new Vector2[xPositions.Length, yPositions.Length];

            for (int x = 0; x < xPositions.Length; x++)
            {
                for (int y = 0; y < yPositions.Length; y++)
                {
                    vectors[x, y] = new Vector2(
                        x: Math.Sin(xPositions[x]),
                        y: Math.Sin(yPositions[y]));
                }
            }

            var vf = plt.AddVectorField(vectors, xPositions, yPositions);

            vf.ScaledArrowheads = true;
            vf.Anchor           = ArrowAnchor.Base;
            vf.MarkerSize       = 3;
        }
コード例 #5
0
ファイル: VectorField.cs プロジェクト: Jmerk523/ScottPlot
        public void ExecuteRecipe(Plot plt)
        {
            double[] xs = DataGen.Range(-1.5, 1.5, .25);
            double[] ys = DataGen.Range(-1.5, 1.5, .25);
            Vector2[,] vectors = new Vector2[xs.Length, ys.Length];

            for (int i = 0; i < xs.Length; i++)
            {
                for (int j = 0; j < ys.Length; j++)
                {
                    double x  = xs[i];
                    double y  = ys[j];
                    var    e  = Math.Exp(-x * x - y * y);
                    var    dx = (1 - 2 * x * x) * e;
                    var    dy = -2 * x * y * e;

                    vectors[i, j] = new Vector2(dx, dy);
                }
            }

            plt.AddVectorField(vectors, xs, ys, scaleFactor: 0.3);
        }
コード例 #6
0
ファイル: VectorField.cs プロジェクト: Jmerk523/ScottPlot
        public void ExecuteRecipe(Plot plt)
        {
            double[] xs = DataGen.Range(-5, 5, .5);
            double[] ys = DataGen.Range(-5, 5, .5);
            Vector2[,] vectors = new Vector2[xs.Length, ys.Length];
            double r = 0.5;


            for (int i = 0; i < xs.Length; i++)
            {
                for (int j = 0; j < ys.Length; j++)
                {
                    double x = ys[j];
                    double y = -9.81 / r * Math.Sin(xs[i]);

                    vectors[i, j] = new Vector2(x, y);
                }
            }

            plt.AddVectorField(vectors, xs, ys, colormap: Drawing.Colormap.Turbo);
            plt.XLabel("θ");
            plt.YLabel("dθ/dt");
        }