コード例 #1
0
        public Plot2D Project(Plot3D p)
        {
            Plot2D plot2D = new Plot2D {
                LinesH = p.LinesH, LinesV = p.LinesV, Size = p.Size
            };

            foreach (PPoint3D point in p.GetPoints())
            {
                var num = (float)Math.Sqrt(point.SquareLen());
                plot2D.AddPoint(new PPoint2D(point.X / num, point.Y / num, point.Color, point.Visible));
            }
            return(plot2D);
        }
コード例 #2
0
        public Plot2D Project(Plot3D p)
        {
            Plot2D plot2D = new Plot2D {
                LinesH = p.LinesH, LinesV = p.LinesV, Size = p.Size
            };

            foreach (PPoint3D point in p.GetPoints())
            {
                plot2D.AddPoint(new PPoint2D(point.X * _ez / point.Z, point.Y * _ez / point.Z, point.Color,
                                             point.Visible));
            }
            return(plot2D);
        }
コード例 #3
0
        public Plot3D Project(Plot2D p)
        {
            Plot3D plot3D = new Plot3D {
                LinesH = p.LinesH, LinesV = p.LinesV, Size = p.Size
            };

            foreach (PPoint2D point in p.GetPoints())
            {
                var num = point.SquareLen();
                plot3D.AddPoint(new PPoint3D((float)(2.0 * point.X / (num + 1.0)),
                                             (float)(2.0 * point.Y / (num + 1.0)), (float)((num - 1.0) / (num + 1.0)), point.Color,
                                             point.Visible));
            }
            return(plot3D);
        }
コード例 #4
0
        public Plot2D UnProject(Plot3D p)
        {
            Plot2D plot2D = new Plot2D {
                LinesH = p.LinesH, LinesV = p.LinesV, Size = p.Size
            };

            foreach (PPoint3D point in p.GetPoints())
            {
                PPoint3D ppoint3D = point;
                plot2D.AddPoint(new PPoint2D(ppoint3D.X / (1f - ppoint3D.Z), ppoint3D.Y / (1f - ppoint3D.Z),
                                             point.Color == Color.Empty
                        ? Extensions.HsvToRgb(360.0 * (point.Z - (double)p.MinZ) / (p.MaxZ - (double)p.MinZ), 1.0, 1.0)
                        : point.Color, point.Visible));
            }
            return(plot2D);
        }
コード例 #5
0
        void SurfacePlot(Plot3D surfacePlot)
        {
            // Example surface plot:
            int nx = 96;
            int ny = 96;
            var x2 = MathHelper.MeshGridX(Enumerable.Range(1, nx).Select(t => (double)t - nx / 2), ny);
            var y2 = MathHelper.MeshGridY(Enumerable.Range(1, ny).Select(t => (double)t - ny / 2), nx);
            var z2 = x2.Zip(y2, (u, v) => Math.Exp((-u * u - v * v) / 400)); // .NET4 method
            //var z2 = x2.Select(u => u * u);
            SurfaceModel3D surface = new SurfaceModel3D(x2, y2, z2, nx, ny);

            surface.Transparency   = 5;
            surface.MeshLines      = MeshLines.None;
            surface.SurfaceShading = SurfaceShading.Smooth;
            surfacePlot.Viewport3D.Models.Add(surface);
            //surfacePlot.LeftLabel.Text = "Left Label"; plot3.BottomLabel.Text = "Bottom Label";
        }
コード例 #6
0
ファイル: MainWindow.xaml.cs プロジェクト: akniyev/omi_kgf
        public MainWindow()
        {
            InitializeComponent();

            // 3D plot
            graphBuilder3dForm = new GraphBuilder2DForm();

            functionPlot3d         = new Plot3D("functionPlot3d");
            coefficientsPlot3d     = new Plot3D("coefficientsPlot3d");
            restoredFunctionPlot3d = new Plot3D("restoredFunctionPlot3d");

            graphBuilder3dForm.GraphBuilder.Set3DMode();
            graphBuilder3dForm.GraphBuilder.ChartPanel.Aspect.Chart3DPercent = 100;

            graphBuilder3dForm.GraphBuilder.DrawPlot(functionPlot3d);
            graphBuilder3dForm.GraphBuilder.DrawPlot(coefficientsPlot3d);
            graphBuilder3dForm.GraphBuilder.DrawPlot(restoredFunctionPlot3d);
            graphBuilder3dForm.Show();

            // 2D plot
            graphBuilder2dForm = new GraphBuilder2DForm();

            originalFPlot        = new Plot2D("original F");
            coefficientsOfFPlot  = new Plot2D("coefficients of F");
            restoredFPlot        = new Plot2D("restored F");
            guessedGPlot         = new Plot2D("guessed G");
            guessedFFromGPlot    = new Plot2D("guessed F from G");
            guessedGCoefficients = new Plot2D("guessed coefficients of G");

            graphBuilder2dForm.GraphBuilder.DrawPlot(originalFPlot);
            graphBuilder2dForm.GraphBuilder.DrawPlot(coefficientsOfFPlot);
            graphBuilder2dForm.GraphBuilder.DrawPlot(restoredFPlot);
            graphBuilder2dForm.GraphBuilder.DrawPlot(guessedGPlot);
            graphBuilder2dForm.GraphBuilder.DrawPlot(guessedFFromGPlot);
            graphBuilder2dForm.GraphBuilder.DrawPlot(guessedGCoefficients);
            graphBuilder2dForm.Show();
        }