我是ILNumerics Visualization Engine的新用户,并且我仍在加快使用方法的速度。我已经广泛搜索了如何更新ILSurface的z值并阅读文章,但是我仍然不清楚如何做到这一点。
我能够生成一个表面并设置一个摄像头进行查看(Hamyo Kutschbach告诉我,这是确保旋转表面时表面长宽比不变的最佳方法,这在我的应用程序)。这是显示sin(x)/ x函数的代码:
// Generate the data
ILArray<double> z = SincFunc(rows, cols, 10, 50);
ILArray<double> x = new double[cols];
ILArray<double> y = new double[rows];
for (int i = 0; i < cols; i++)
x[i] = (double)i;
for (int i = 0; i < rows; i++)
y[i] = (double)i;
// create the scene
scene = new ILScene();
pointCloudSurface = new ILSurface(z, x, y)
{
Colormap = Colormaps.Jet,
UseLighting = true,
Wireframe = { Visible = false },
Children = { new ILColorbar()
{
Height = 0.5f,
Location = new PointF(0.95f, 0.05f),
Children = { new ILLabel("microns") { Position = new Vector3(0.5,1,0), Anchor = new PointF(0.5f,0) } } }
},
Alpha = 1.0f
};
// Configure the surface and display it
scene.Camera.Add(pointCloudSurface);
scene.Camera.Position = new Vector3(50, 50, 700);
scene.Camera.LookAt = new Vector3(50, 50, 0);
scene.Camera.Top = new Vector3(0, 0, 700);
scene.Camera.Projection = Projection.Perspective;
scene.Camera.ZNear = 1.0f;
scene.Camera.ZFar = 0.0f;
scene.Camera.Top = new Vector3(1, 0, 0);
// Turn off the Powered by ILNumerics label
scene.Screen.First<ILLabel>().Visible = false;
ilPanel1.Scene = scene;
ilPanel1.Configure();
ilPanel1.Refresh();
而且效果很好。现在,我想更改z值并更新图而不关闭ilPanel1,因为该图已嵌入Windows窗体中。意见将不胜感激!希望其他新手也会发现这篇文章也有用。
答案 0 :(得分:1)
经过进一步的摸索,我遇到了一种方法,UpdateColormapped(),可以达到目的。像这样放在上面的代码结尾处:
scene.Camera.First<ILSurface>().UpdateColormapped(z);
ilPanel1.Scene = scene;
ilPanel1.Configure();
ilPanel1.Refresh();
可以在以下API文档中找到它:UpdateColormapped()
它也可以更改x和y数据并执行其他mod,但是它要求z数据为浮点数组,因此,如果您正在使用双精度,则必须采取适当的步骤来获取它放入一个float数组。