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: 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.