繁体   English   中英

使用带有xyz坐标和jzy3d的3d表面图

[英]Build a 3d surface plot using xyz coordinates with jzy3d

我一直在寻找一种将coord(x,y,z)列表发送到jzy3d的方法。 但是没有成功。

我发现的唯一方法是使用带有列表“ coord3d”和“ tesselator”的“ builder”,但实际上不起作用。

我真的不了解Tesselator的意思吗?

这是我尝试的代码:

public Chart getChart(){

    List<Coord3d> coordinates = new ArrayList<Coord3d>();
    for(int i=0; i<200; i++)
        coordinates.add( new Coord3d(5, 10, 15) );
    Tesselator tesselator = new Tesselator() {          
        @Override
        public AbstractComposite build(float[] x, float[] y, float[] z) {
            return null;
        }
    };      
    tesselator.build(coordinates);
     org.jzy3d.plot3d.primitives.Shape surface = (Shape)Builder.build(coordinates, tesselator);


/*/ 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("swing");
  chart.getScene().getGraph().add(surface);
  return chart;
}

有人可以告诉我如何用许多XYZ坐标系喂我的图形,以便我可以像这样获得3d表面图:

3D表面图
(来源: free.fr

镶嵌器允许从点列表中创建多边形。 Jzy3d提供了两个基本的细分器:一个支持位于规则网格上的点(称为OrthonormalTesselator),一个支持将非结构化点作为输入(DelaunayTesselator)。 第二个问题并不总是“运作良好”:这不是有关其实现的问题,主要是以下事实:很难决定点应如何协同工作以在3d中形成多边形。 您可以在Jzy3d Wiki和讨论组上找到有关它的一些讨论。

要手动构建多边形,请执行以下操作:

// Build a polygon list
    double [][]distDataProp = new double[][] {{.25,.45, .20},{.56, .89, .45}, {.6, .3,.7}};
    List<Polygon> polygons = new ArrayList<Polygon>();
    for(int i = 0; i < distDataProp.length -1; i++){
        for(int j = 0; j < distDataProp[i].length -1; j++){
            Polygon polygon = new Polygon();
            polygon.add(new Point( new Coord3d(i, j, distDataProp[i][j]) ));
            polygon.add(new Point( new Coord3d(i, j+1, distDataProp[i][j+1]) ));
            polygon.add(new Point( new Coord3d(i+1, j+1, distDataProp[i+1][j+1]) ));
            polygon.add(new Point( new Coord3d(i+1, j, distDataProp[i+1][j]) ));
            polygons.add(polygon);
        }
    }

    // Creates the 3d object
    Shape surface = new Shape(polygons);
    surface.setColorMapper(new ColorMapper(new ColorMapRainbow(), surface.getBounds().getZmin(), surface.getBounds().getZmax(), new org.jzy3d.colors.Color(1,1,1,1f)));
    surface.setWireframeDisplayed(true);
    surface.setWireframeColor(org.jzy3d.colors.Color.BLACK);

    chart = new Chart();
    chart.getScene().getGraph().add(surface);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM