编辑和新答案与解决方案
经过一番调查后,您的问题可能会重现。实际上我们有两个问题:
1)旋转绘图立方体以翻转轴就可以了。但应该正确地进行。这涉及到一个旋转and一个翻译。两者可以组合并一起应用于ILPlotCube.Rotation
财产:
Rotation = Matrix4.Translation(0, 0, -2).Rotate(Vector3.UnitX, ILMath.pif)
需要平移,因为旋转总是围绕原点进行。绘图立方体的原点位于 (0,0,0),绕 X 轴旋转使绘图立方体更靠近相机。如果没有平移,它可能会太接近,从而导致 ZNear 上的剪辑启动并阻止场景的某些部分显示。
2) BUTILNumerics 中存在错误ILOGLLabel
ILNumerics 的 OpenGL 标签类先前版本 4.1 将阻止标签在此类旋转的绘图立方体中显示。该错误将在 4.1 中修复。
为了解决这个错误,
a. Use ILPlotCube.Transform
代替ILPlotCube.Rotation
, and
b.重新配置设置ILPlotCube.ZNear
and ILPlotCube.ZFar
:
plotCube.Transform = Matrix4.Translation(0, 0, -2).Rotate(Vector3.UnitX, ILMath.pif);
plotCube.ZNear = -1; plotCube.ZFar = 1;
Recap
要使用 ILNumerics 版本 > 4.0 反转 Y 轴,只需应用 1)。对于旧版本(4.0 及以下),只需使用 2)。
旧答案
@编辑:旧答案并没有真正回答问题。请参阅上面的第一部分以找到原始问题的解决方案。为了完整起见,这个旧答案留在这里,因为它无论如何都是有用的:它展示了如何通过允许用户交互来确保稳定的配置。
我无法完全重现您的问题,但这里有一个潜在的解决方案。
通过反转绘图立方体以获得从上到下方向的 Y 轴,您必须确保用户无法通过双击场景来重置绘图立方体。我们可以处理双击事件并将旋转放在那里。
无论如何,对于下面的示例,所有刻度都正确显示。如果问题仍然存在,请发布屏幕截图和runnable例子。
private void ilPanel1_Load(object sender, EventArgs e) {
// generate some test data
ILArray<float> A = ILMath.tosingle(ILMath.randn(1, 20));
ILArray<float> B = A + ILMath.vec<float>(1, 20);
// add two lines
ilPanel1.Scene.Add(new ILPlotCube {
Children = {
new ILLinePlot(A, lineWidth:1, markerStyle: MarkerStyle.None),
new ILLinePlot(B, lineColor: Color.Black, lineWidth: 2)
},
// rotate the plotcube so the Y axis appears in top down direction
Rotation = Matrix4.Rotation(new Vector3(1, 0, 0), ILMath.pif), //<<==== added this line
// configure some axis label properties
Axes = {
YAxis = {
LabelAnchor = new PointF(1, 0)
},
ZAxis = {
Visible = false,
}
}
});
// override the double click event: resetting the plotcube will restore the reversed axis
ilPanel1.Scene.First<ILPlotCube>().MouseDoubleClick += (_s, _a) => {
var plotCube = _s as ILPlotCube;
if (plotCube != null) {
plotCube.Reset();
plotCube.Rotation = Matrix4.Rotation(new Vector3(1, 0, 0), ILMath.pif);
_a.Refresh = true;
_a.Cancel = true;
}
};
}