0

Hi guys I have some problems when I'm trying to draw 3D function with c#

My code:

string expr = "Abs(x)+Abs(y)";
int pointX = 43;
int pointNumber = pointX * pointX;
double[] XX = new double[pointX];
double[] YY = new double[pointX];
double[,] ZZ = new double[pointX, pointX];
for (int i = 0; i < pointX; i++)
{
    double d = (double)i;
    XX[i] = YY[i] = -10 + 20 * (d / (pointX - 1));
    if (XX[i] == 0) { XX[i] = 0.01; YY[i] = 0.01; }
}
Parser p = new Parser();
for (int j = 0; j < pointX; j++)
{
    for (int k = 0; k < pointX; k++)
    {
        Hashtable h = new Hashtable();
        h.Add("x", XX[j]);
        h.Add("y", YY[k]);
        ZZ[j, k] = p.Parse(expr, h);

    }
}

Then in internet I tomot give me this piece of code for drawing 3d function with IlNumerics:

       This code is too old

But when I'm trying to run the code the CIL give me some error because meshgrid now is a different method and IlSurfaceGraph and m_panel2.Graphs.AddSurfGraph don't exist anymore.

How can I solve this?

EDIT 1

I have read again the documentation and I have tryed this code for creating the 3D chart:

ILArray<float> Z = ZZ;
ilPanel1.Scene = new ILScene() {
    new ILPlotCube(twoDMode: false) {
        new ILSurface(ZZ) {
            UseLighting = true
        }
    }
};
ilPanel1.Scene.First<ILPlotCube>().Rotation = Matrix4.Rotation(
    new Vector3(1f, 0.23f, 1), 0.7f);

ILArray is not empty and the result is this: enter image description here I don't understand why the Graph is empty...

Number of float in matrix 1849. Here you can see all the output(It's too long so I have posted on pastebin). The example works perfectly there are no problem with they.

Tinwor
  • 7,765
  • 6
  • 35
  • 56
  • "CIL give me some error" ... what error exactly? – Ondrej Janacek Dec 07 '13 at 17:51
  • It says that the method that I want to use don't exist anymore. I have surfed around the IlNumerics API but I have found nothing :S – Tinwor Dec 07 '13 at 17:54
  • Did you try to surf to the documentation: http://ilnumerics.net/surface-plots.html ? The answer to your other question (http://stackoverflow.com/questions/20412951/how-to-plot-3d-function-using-ilpanel-c-sharp) may be of help also? – Haymo Kutschbach Dec 07 '13 at 18:46
  • @HaymoKutschbach Yes I have read the documentation and I have follow your suggestions but I don't understand how to transform the code that I have for the latest version of IlNumerics – Tinwor Dec 08 '13 at 20:52
  • Which part dont you understand? The ILNumerics related part is outdated. You should replace it with the new version. The documentation gives plenty of examples. Since the result of your evaluation seems to exist as matrix Z, it should be straightforward to use one of the examples in order to create a surface for Z? If not: help us to understand the problem more clearly! – Haymo Kutschbach Dec 08 '13 at 21:11
  • @HaymoKutschbach I have tryed again and I have posted the code that I have used in the Question – Tinwor Dec 08 '13 at 23:11
  • Please set a breakpoint at the line where the surface is created and inspect ZZ. Can you print the size and content of ZZ, please? And what is Z for? It seems it is not being used anywhere? – Haymo Kutschbach Dec 09 '13 at 23:06
  • Does any other example work on your machine? Please post your configuration: os, video card, .net version ? Any error message? – Haymo Kutschbach Dec 09 '13 at 23:10

0 Answers0