Jzy3d三维插值图表无法渲染问题求助
使用Jzy3d绘制三维贝塞尔插值路径
我最近在尝试基于一组坐标点绘制三维路径,翻了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, 2.0, 1.0)); controlCoords.add(new Coord3d(2.0, 1.0, 3.0)); controlCoords.add(new Coord3d(3.0, 3.0, 2.0)); // 可根据需求继续添加更多控制点 // 创建经过插值处理的三维线条 LineStripInterpolated lineStrip = new LineStripInterpolated(controlCoords, interp); lineStrip.setWidth(2f); lineStrip.setColor(Color.BLUE); // 初始化Jzy3d图表并将路径添加到场景中 Chart chart = new Chart(Quality.Advanced); chart.getScene().getGraph().add(lineStrip); chart.open("3D Interpolated Path", 800, 600); }
额外说明
BernsteinInterpolator是Jzy3d内置的贝塞尔插值实现,默认就能生成平滑的过渡曲线LineStripInterpolated的作用是将离散的控制点通过插值器转换为连续的三维线条- 如果想要更精细的平滑效果,可以调用
lineStrip.setInterpolationSteps(xxx)来调整插值步数,数值越大线条的平滑度越高
内容的提问来源于stack exchange,提问作者schan
相关产品推荐
相关产品推荐

