gpt4 book ai didi

java - 如何使用Jzy3d java 3d图表库?

转载 作者:行者123 更新时间:2023-12-01 05:36:54 25 4
gpt4 key购买 nike

有人可以给我一些额外的基本示例吗jzy3d应该使用吗?
(源网站的示例似乎不适合我)

我尝试了以下代码:

import org.jzy3d.chart.Chart;
import org.jzy3d.colors.Color;
import org.jzy3d.colors.ColorMapper;
import org.jzy3d.colors.colormaps.ColorMapRainbow;
import org.jzy3d.maths.Range;
import org.jzy3d.plot3d.builder.Builder;
import org.jzy3d.plot3d.builder.Mapper;
import org.jzy3d.plot3d.builder.concrete.OrthonormalGrid;
import org.jzy3d.plot3d.primitives.Shape;

public class Test {

public static void main(String[] args) {

JFrame frame = new JFrame();
Chart chart = getChart();

frame.add((javax.swing.JComponent) chart.getCanvas());

frame.setSize(800, 800);
frame.setLocationRelativeTo(null);
frame.setTitle("test");
frame.setVisible(true);
}

public static Chart getChart() {
// Define a function to plot
Mapper mapper = new Mapper() {
public double f(double x, double y) {
return 10 * Math.sin(x / 10) * Math.cos(y / 20) * x;
}
};

// Define range and precision for the function to plot
Range range = new Range(-150, 150);
int steps = 50;

// Create the object to represent the function over the given range.
org.jzy3d.plot3d.primitives.Shape surface = (Shape) Builder.buildOrthonormal(new OrthonormalGrid(range, steps, range, steps), mapper);
surface.setColorMapper(new ColorMapper(new ColorMapRainbow(), surface.getBounds().getZmin(), surface.getBounds().getZmax(), new Color(1, 1, 1, .5f)));
surface.setWireframeDisplayed(true);
surface.setWireframeColor(Color.BLACK);
//surface.setFace(new ColorbarFace(surface));
surface.setFaceDisplayed(true);
//surface.setFace2dDisplayed(true); // opens a colorbar on the right part of the display

// Create a chart
Chart chart = new Chart();
chart.getScene().getGraph().add(surface);
return chart;
}
}

但是当我尝试运行它时,我遇到了异常:

Exception in thread "main" java.lang.UnsatisfiedLinkError: no jogl in java.library.path

有人可以帮忙吗?

最佳答案

您应该将 jogl.jar 添加到类路径,将 jogl.dll 添加到 PATH。
欲了解更多信息,请查看herehere .

您可以阅读jogl 安装说明 here

关于java - 如何使用Jzy3d java 3d图表库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8048028/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com