带有x y z数据的ILNumerics三维曲面图c#

时间:2015-01-12 02:47:42

标签: c# ilnumerics

我有一个包含大约5000万xyz数据点的文件,并且我试图在此数据集中的每百分之一点创建一个表面图,但由于某种原因,我的情节总是出现看起来可怕的变形。这是我的代码,它制作了我正在绘制的三维数据矩阵:

        //Extracting data from file up here ^^^

        //This block of code creates 1 dimensional array's for every 100th x, y and z point
        for (int count = 0; count < lineCount; count++)
        {
            if (count % 100 == 0)
            {
                refinedX[count / 100] = rawX[count];
                refinedY[count / 100] = rawY[count];
                refinedZ[count / 100] = rawZ[count];
            }
            if (count % deltaL == 0)
            {
                openBackGroundCalc.ReportProgress((int)(count / deltaL));
            }
        }

        //Finding the width of the square matrix because the matrices have to be square? this is probably the bad step..
        matrixWidth = (int) Math.Sqrt(refinedX.Length);

        xMatrix = new ILArray<double>[matrixWidth, matrixWidth];
        yMatrix = new ILArray<double>[matrixWidth, matrixWidth];
        zMatrix = new ILArray<double>[matrixWidth, matrixWidth];

        //Turning my one dimensional x,y,z arrays into 2 dimensional x,y and z matrices
        for (int r = 0; r < matrixWidth; r++)
        {
            for (int c = 0; c < matrixWidth; c++)
            {
                xMatrix[r, c] = refinedX[r + c];
                yMatrix[r, c] = refinedY[r + c];
                zMatrix[r, c] = refinedZ[r + c];
            }
        }
        //Combining the three matrices into one 3 dimensional matrix
        surfaceData = new ILArray<double>[matrixWidth, matrixWidth, 3];
        surfaceData[":;:;0"] = zMatrix;
        surfaceData[":;:;1"] = xMatrix;
        surfaceData[":;:;2"] = yMatrix;

        //Adding the surface plot to the scene
        threeCube.Add(new ILSurface(surfaceData));

        surfaceData.Name = "surface";
        rawX.Name = "raw_x";
        rawY.Name = "raw_y";
        rawZ.Name = "raw_z";

        //Saving the data for later use.. not important for this issue
        using (ILMatFile matWrite = new ILMatFile())
        {
            matWrite.AddArray(surfaceData);
            matWrite.AddArray(rawX);
            matWrite.AddArray(rawY);
            matWrite.AddArray(rawZ);

            matWrite.Write(matFilePath);
        }
    }

以下是绘制它的代码:

        private void plot()
    {
        //LOCAL DECLARATIONS

        //EXECUTABLE STATEMENTS
        switch(graphType)
        {
            case "3DThermal":
                mainPanelView.Scene = threeDThermal;

                break;

            case "2DThermal":

                break;

            default:
                MessageBox.Show("Error!\nHard coded graph format missing", "Invalid Format", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                break;
        }
    }

然后我的情节出现了所有看到齿状而不是流动的表面..我道歉,如果这是一个非常明显的问题,我对此很新。请尝试在您的答案中包含代码,提前感谢:)

0 个答案:

没有答案