Jzy3d 3d插值图不渲染
Jzy3d 3d interpolation plots not rendering
我正在尝试绘制给定一组坐标的 3d 路径。从 jzy3d 的演示应用程序中,我发现这可以通过他们的 BernsteinInterpolator
和 LineStripInterpolated
类.
借助他们的源代码,我尝试重现如下:
public static void main(String[] args) {
BernsteinInterpolator interp = new BernsteinInterpolator();
List<Coord3d> controlCoords = new ArrayList<>();
controlCoords.add(new Coord3d(0.0, 0.0, 0.0));
controlCoords.add(new Coord3d(1.0, 0.0, 1.0));
controlCoords.add(new Coord3d(1.0, 0.0, 2.0));
controlCoords.add(new Coord3d(1.0, 1.0, 2.0));
controlCoords.add(new Coord3d(0.0, 1.0, 2.0));
controlCoords.add(new Coord3d(3.0, 2.0, -1.0));
LineStripInterpolated line = new LineStripInterpolated(interp, controlCoords, 30);
Chart chart = new AWTChart(Quality.Intermediate);
chart.add(line);
chart.open("chart test", 600, 600);
}
根据演示应用程序,这是我希望得到的 -> DemoPlot
不幸的是,上面只呈现空白 window,没有错误或异常。有谁知道出了什么问题?非常感谢您的帮助!
所以我深入研究了源代码,发现有一种方法可以绕过 LineStripInterpolated
class 如下:
public static void main(String[] args) {
List<Coord3d> controlCoords = new ArrayList<>();
controlCoords.add(new Coord3d(0.0F, 0.0F, 0.0F));
controlCoords.add(new Coord3d(1.0F, 0.0F, 1.0F));
controlCoords.add(new Coord3d(1.0F, 0.0F, 2.0F));
controlCoords.add(new Coord3d(1.0F, 1.0F, 2.0F));
controlCoords.add(new Coord3d(0.0F, 1.0F, 2.0F));
controlCoords.add(new Coord3d(3.0F, 2.0F, -1.0F));
BernsteinInterpolator interp = new BernsteinInterpolator();
List<Coord3d> interpolatedCoords = interp.interpolate(controlCoords, 30);
List<Point> controlPoints = new ArrayList<>();
for (Coord3d coord : controlCoords) {
controlPoints.add(new Point(coord, Color.RED, 5.0));
}
List<Point> interpPoints = new ArrayList<>();
for (Coord3d coord : interpolatedCoords) {
interpPoints.add(new Point(coord, Color.BLUE, 3.0));
}
LineStrip line = new LineStrip(interpolatedCoords);
line.setWireframeColor(Color.BLACK);
Chart chart = new AWTChart(Quality.Intermediate);
chart.add(line);
chart.add(controlPoints);
chart.add(interpPoints);
chart.open("chart test", 600, 600);
}
希望这对遇到同样问题的其他人有所帮助。我仍然很好奇为什么我以前的方法不起作用。 :(
我正在尝试绘制给定一组坐标的 3d 路径。从 jzy3d 的演示应用程序中,我发现这可以通过他们的 BernsteinInterpolator
和 LineStripInterpolated
类.
借助他们的源代码,我尝试重现如下:
public static void main(String[] args) {
BernsteinInterpolator interp = new BernsteinInterpolator();
List<Coord3d> controlCoords = new ArrayList<>();
controlCoords.add(new Coord3d(0.0, 0.0, 0.0));
controlCoords.add(new Coord3d(1.0, 0.0, 1.0));
controlCoords.add(new Coord3d(1.0, 0.0, 2.0));
controlCoords.add(new Coord3d(1.0, 1.0, 2.0));
controlCoords.add(new Coord3d(0.0, 1.0, 2.0));
controlCoords.add(new Coord3d(3.0, 2.0, -1.0));
LineStripInterpolated line = new LineStripInterpolated(interp, controlCoords, 30);
Chart chart = new AWTChart(Quality.Intermediate);
chart.add(line);
chart.open("chart test", 600, 600);
}
根据演示应用程序,这是我希望得到的 -> DemoPlot
不幸的是,上面只呈现空白 window,没有错误或异常。有谁知道出了什么问题?非常感谢您的帮助!
所以我深入研究了源代码,发现有一种方法可以绕过 LineStripInterpolated
class 如下:
public static void main(String[] args) {
List<Coord3d> controlCoords = new ArrayList<>();
controlCoords.add(new Coord3d(0.0F, 0.0F, 0.0F));
controlCoords.add(new Coord3d(1.0F, 0.0F, 1.0F));
controlCoords.add(new Coord3d(1.0F, 0.0F, 2.0F));
controlCoords.add(new Coord3d(1.0F, 1.0F, 2.0F));
controlCoords.add(new Coord3d(0.0F, 1.0F, 2.0F));
controlCoords.add(new Coord3d(3.0F, 2.0F, -1.0F));
BernsteinInterpolator interp = new BernsteinInterpolator();
List<Coord3d> interpolatedCoords = interp.interpolate(controlCoords, 30);
List<Point> controlPoints = new ArrayList<>();
for (Coord3d coord : controlCoords) {
controlPoints.add(new Point(coord, Color.RED, 5.0));
}
List<Point> interpPoints = new ArrayList<>();
for (Coord3d coord : interpolatedCoords) {
interpPoints.add(new Point(coord, Color.BLUE, 3.0));
}
LineStrip line = new LineStrip(interpolatedCoords);
line.setWireframeColor(Color.BLACK);
Chart chart = new AWTChart(Quality.Intermediate);
chart.add(line);
chart.add(controlPoints);
chart.add(interpPoints);
chart.open("chart test", 600, 600);
}
希望这对遇到同样问题的其他人有所帮助。我仍然很好奇为什么我以前的方法不起作用。 :(