// function for testing surface chart
        public void TestSurfacePlot(int nGridNo, float xMin, float xMax, float yMin, float yMax, Func <double, double, double> f)
        {
            int nXNo = nGridNo;
            int nYNo = nGridNo;

            // 1. set the surface grid
            m_3dChart = new UniformSurfaceChart3D();
            ((UniformSurfaceChart3D)m_3dChart).SetGrid(nXNo, nYNo, xMin, xMax, yMin, yMax);

            // 2. set surface chart z value
            double xC      = m_3dChart.XCenter();
            double yC      = m_3dChart.YCenter();
            int    nVertNo = m_3dChart.GetDataNo();
            double zV;

            for (int i = 0; i < nVertNo; i++)
            {
                Vertex3D vert = m_3dChart[i];

                //double r = 0.15 * Math.Sqrt((vert.x - xC) * (vert.x - xC) + (vert.y - yC) * (vert.y - yC));
                //if (r < 1e-10)
                //    zV = 1;
                //else
                //    zV = Math.Sin(r) / r;

                m_3dChart[i].z = (float)f(vert.x, vert.y);
            }
            m_3dChart.GetDataRange();

            // 3. set the surface chart color according to z vaule
            double zMin = m_3dChart.ZMin();
            double zMax = m_3dChart.ZMax();

            for (int i = 0; i < nVertNo; i++)
            {
                Vertex3D vert = m_3dChart[i];
                double   h    = (vert.z - zMin) / (zMax - zMin);

                Color color = WPFChart3D.TextureMapping.PseudoColor(h);
                m_3dChart[i].color = color;
            }

            // 4. Get the Mesh3D array from surface chart
            ArrayList meshs = ((UniformSurfaceChart3D)m_3dChart).GetMeshes();

            // 6. Set the model display of surface chart
            WPFChart3D.Model3D model3d      = new WPFChart3D.Model3D();
            Material           backMaterial = new DiffuseMaterial(new SolidColorBrush(Colors.Gray));

            m_nChartModelIndex = model3d.UpdateModel(meshs, backMaterial, m_nChartModelIndex, this.mainViewport);

            // 7. set projection matrix, so the data is in the display region
            xMin = m_3dChart.XMin();
            xMax = m_3dChart.XMax();
            m_transformMatrix.CalculateProjectionMatrix(xMin, xMax, xMin, xMax, zMin, zMax, 0.5);
            TransformChart();
        }
示例#2
0
        public Window1()
        {
            InitializeComponent();

            // selection rect
            m_selectRect.SetRect(new Point(-0.5, -0.5), new Point(-0.5, -0.5));
            WPFChart3D.Model3D model3d = new WPFChart3D.Model3D();
            ArrayList          meshs   = m_selectRect.GetMeshes();

            totalMatrixInitial = this.m_transformMatrix.m_totalMatrix;
        }
示例#3
0
        // function for testing 3d scatter plot
        public void TestScatterPlot(int nDotNo)
        {
            // 1. set scatter chart data no.
            m_3dChart = new ScatterChart3D();
            m_3dChart.SetDataNo(nDotNo);

            // 2. set property of each dot (size, position, shape, color)
            Random randomObject = new Random();
            int    nDataRange   = 200;

            for (int i = 0; i < nDotNo; i++)
            {
                ScatterPlotItem plotItem = new ScatterPlotItem();

                plotItem.w = 4;
                plotItem.h = 6;

                plotItem.x = (float)randomObject.Next(nDataRange);
                plotItem.y = (float)randomObject.Next(nDataRange);
                plotItem.z = (float)randomObject.Next(nDataRange);

                plotItem.shape = randomObject.Next(4);

                Byte nR = (Byte)randomObject.Next(256);
                Byte nG = (Byte)randomObject.Next(256);
                Byte nB = (Byte)randomObject.Next(256);

                plotItem.color = Color.FromRgb(nR, nG, nB);
                ((ScatterChart3D)m_3dChart).SetVertex(i, plotItem);
            }

            // 3. set the axes
            m_3dChart.GetDataRange();
            m_3dChart.SetAxes();

            // 4. get Mesh3D array from the scatter plot
            ArrayList meshs = ((ScatterChart3D)m_3dChart).GetMeshes();

            // 5. display model vertex no and triangle no
            UpdateModelSizeInfo(meshs);

            // 6. display scatter plot in Viewport3D
            WPFChart3D.Model3D model3d = new WPFChart3D.Model3D();
            m_nChartModelIndex = model3d.UpdateModel(meshs, null, m_nChartModelIndex, this.mainViewport);

            // 7. set projection matrix
            float viewRange = (float)nDataRange;

            m_transformMatrix.CalculateProjectionMatrix(0, viewRange, 0, viewRange, 0, viewRange, 0.5);
            TransformChart();
        }
示例#4
0
        public SurfacePlotWindow(double xMin, double xMax, double yMin, double yMax, Func<double, double, double> f)
        {
            InitializeComponent();

            // selection rect
            m_selectRect.SetRect(new Point(-0.5, -0.5), new Point(-0.5, -0.5));
            WPFChart3D.Model3D model3d = new WPFChart3D.Model3D();
            ArrayList meshs = m_selectRect.GetMeshes();
            m_nRectModelIndex = model3d.UpdateModel(meshs, null, m_nRectModelIndex, this.mainViewport);

            // display surface chart
            TestSurfacePlot(100, (float)xMin, (float)xMax, (float)yMin, (float)yMax, f);
            TransformChart();
        }
        public SurfacePlotWindow(double xMin, double xMax, double yMin, double yMax, Func <double, double, double> f)
        {
            InitializeComponent();

            // selection rect
            m_selectRect.SetRect(new Point(-0.5, -0.5), new Point(-0.5, -0.5));
            WPFChart3D.Model3D model3d = new WPFChart3D.Model3D();
            ArrayList          meshs   = m_selectRect.GetMeshes();

            m_nRectModelIndex = model3d.UpdateModel(meshs, null, m_nRectModelIndex, this.mainViewport);


            // display surface chart
            TestSurfacePlot(100, (float)xMin, (float)xMax, (float)yMin, (float)yMax, f);
            TransformChart();
        }
示例#6
0
        public Window1()
        {
            InitializeComponent();

            // selection rect
            m_selectRect.SetRect(new Point(-0.5, -0.5), new Point(-0.5, -0.5));
            WPFChart3D.Model3D model3d = new WPFChart3D.Model3D();
            ArrayList          meshs   = m_selectRect.GetMeshes();

            m_nRectModelIndex = model3d.UpdateModel(meshs, null, m_nRectModelIndex, this.mainViewport);

            // display the 3d chart data no.
            gridNo.Text = String.Format("{0:d}", m_nSurfaceChartGridNo);
            dataNo.Text = String.Format("{0:d}", m_nScatterPlotDataNo);

            // display surface chart
            TestScatterPlot(1000);
            TransformChart();
        }
示例#7
0
        // function for testing surface chart
        public void TestSurfacePlot(int nGridNo, float xMin, float xMax, float yMin, float yMax, Func<double, double, double> f)
        {
            int nXNo = nGridNo;
            int nYNo = nGridNo;
            // 1. set the surface grid
            m_3dChart = new UniformSurfaceChart3D();
            ((UniformSurfaceChart3D)m_3dChart).SetGrid(nXNo, nYNo, xMin, xMax, yMin, yMax);

            // 2. set surface chart z value
            double xC = m_3dChart.XCenter();
            double yC = m_3dChart.YCenter();
            int nVertNo = m_3dChart.GetDataNo();
            double zV;
            for (int i = 0; i < nVertNo; i++) {
                Vertex3D vert = m_3dChart[i];

                //double r = 0.15 * Math.Sqrt((vert.x - xC) * (vert.x - xC) + (vert.y - yC) * (vert.y - yC));
                //if (r < 1e-10)
                //    zV = 1;
                //else
                //    zV = Math.Sin(r) / r;

                m_3dChart[i].z = (float)f(vert.x, vert.y);
            }
            m_3dChart.GetDataRange();

            // 3. set the surface chart color according to z vaule
            double zMin = m_3dChart.ZMin();
            double zMax = m_3dChart.ZMax();
            for (int i = 0; i < nVertNo; i++) {
                Vertex3D vert = m_3dChart[i];
                double h = (vert.z - zMin) / (zMax - zMin);

                Color color = WPFChart3D.TextureMapping.PseudoColor(h);
                m_3dChart[i].color = color;
            }

            // 4. Get the Mesh3D array from surface chart
            ArrayList meshs = ((UniformSurfaceChart3D)m_3dChart).GetMeshes();

            // 6. Set the model display of surface chart
            WPFChart3D.Model3D model3d = new WPFChart3D.Model3D();
            Material backMaterial = new DiffuseMaterial(new SolidColorBrush(Colors.Gray));
            m_nChartModelIndex = model3d.UpdateModel(meshs, backMaterial, m_nChartModelIndex, this.mainViewport);

            // 7. set projection matrix, so the data is in the display region
            xMin = m_3dChart.XMin();
            xMax = m_3dChart.XMax();
            m_transformMatrix.CalculateProjectionMatrix(xMin, xMax, xMin, xMax, zMin, zMax, 0.5);
            TransformChart();
        }
示例#8
0
        public void TestSimpleScatterPlot(double[,] coordinates, int numberOfPointsInCuttingRegion)
        {
            distance++;
            mygrid.UpdateLayout();
            int nDotNo = coordinates.GetLength(0);

            // 1. set the scatter plot size
            m_3dChart = new ScatterChart3D();
            m_3dChart.SetDataNo(nDotNo);

            // 2. set the properties of each dot
            Random randomObject = new Random();
            int    nDataRange   = 40;

            for (int i = 0; i < nDotNo; i++)
            {
                ScatterPlotItem plotItem = new ScatterPlotItem();

                plotItem.x = (float)coordinates[i, 0];
                plotItem.y = (float)coordinates[i, 1];
                plotItem.z = (float)coordinates[i, 2];

                if (numberOfFlutes == 0)
                {
                    label.Content = "Distance travelled by tool = " + distance + " mm.";
                    if (i < numberOfPointsInCuttingRegion)
                    {
                        plotItem.w     = 0.25f;
                        plotItem.h     = 0.10f;
                        plotItem.shape = (int)Chart3D.SHAPE.BAR;
                        plotItem.color = Color.FromArgb(200, (byte)(160), (byte)(5), (byte)(5));
                    }
                    else
                    {
                        plotItem.w     = 0.05f;
                        plotItem.h     = 0.1f;
                        plotItem.shape = (int)Chart3D.SHAPE.BAR;
                        plotItem.color = Color.FromArgb(200, (byte)(160), (byte)(160), (byte)(160));
                    }
                }
                else
                {
                    label.Content = ("");
                    if (((int)(i / Lp)) % (Kp / numberOfFlutes) == 0)
                    {
                        int n = (int)(((int)(i / Lp)) / (Kp / numberOfFlutes));
                        plotItem.w     = 0.8f;
                        plotItem.h     = 0.20f;
                        plotItem.shape = (int)Chart3D.SHAPE.PYRAMID;
                        //plotItem.color = Color.FromArgb(200, (byte)(80), (byte)(80), (byte)(60));
                        plotItem.color = Color.FromArgb(1, (byte)(60 + 20 * n), (byte)(60 + 20 * n), (byte)(30 + 40 * n));
                    }
                    else
                    {
                        plotItem.w     = 0.2f;
                        plotItem.h     = 0.10f;
                        plotItem.shape = (int)Chart3D.SHAPE.BAR;
                        plotItem.color = Color.FromArgb(1, (byte)(160), (byte)(160), (byte)(160));
                    }
                }
                ((ScatterChart3D)m_3dChart).SetVertex(i, plotItem);
            }
            // 3. set axes
            m_3dChart.GetDataRange();
            m_3dChart.SetAxes();

            // 4. Get Mesh3D array from scatter plot
            ArrayList meshs = ((ScatterChart3D)m_3dChart).GetMeshes();

            // 5. display vertex no and triangle no.
            UpdateModelSizeInfo(meshs);

            // 6. show 3D scatter plot in Viewport3d
            WPFChart3D.Model3D model3d = new WPFChart3D.Model3D();
            m_nChartModelIndex = model3d.UpdateModel(meshs, null, m_nChartModelIndex, this.mainViewport);

            // 7. set projection matrix
            float viewRange = (float)nDataRange;

            m_transformMatrix.CalculateProjectionMatrix(0, viewRange, 0, viewRange, 0, viewRange, 0.5);
            TransformChart();
            mainViewport.UpdateLayout();
        }