簡體   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