建立使用XYZ三维曲面图与jzy3d坐标 [英] Build a 3d surface plot using xyz coordinates with jzy3d
问题描述
我一直在寻找一种方式来发送的坐标(X,Y,Z)的列表jzy3d。但是没有成功。
I've been searching for a way to send a list of coord(x,y,z) to jzy3d. But without success.
我发现的唯一方法是使用一个工程师与coord3d和tesselator的名单,但它实际上是行不通的。
The only way I found is to use a "builder" with a list of "coord3d" and a "tesselator", but it actually doesn't work.
我不真的得到Tesselator的意思,其实?
I don't realy get the meaning of the Tesselator in fact ?
下面是code我想:
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 coordonates我的图,这样我可能会得到这样一个三维曲面图:
Could someone please tell me how to feed my graph with many XYZ coordonates so that I may get a 3d surface plot like this one :
推荐答案
一个tesselator允许创建出多边形点列表中。 Jzy3d提供了两个基地tesselators:一个支持点,站在一个普通网格(称为OrthonormalTesselator),一种支持非结构化点作为输入(DelaunayTesselator)。第二个是不总是好工作:不是关于它的实现,但主要是事实,这是很难决定点应该如何共同努力,形成3D多边形的问题。您可能会发现关于它的Jzy3d wiki和讨论组的一些讨论。
A tesselator allows creating polygons out of a list of points. Jzy3d provides two base tesselators: one that supports points standing on a regular grid (called OrthonormalTesselator), one that supports unstructured points as input (DelaunayTesselator). The second one is not always "working good": not a problem concerning its implementation but mainly the fact that it's difficult to decide how points should work together to form a polygon in 3d. You may find some discussions about it on Jzy3d wiki and discussion groups.
要手动生成多边形,这里就是你应该做的:
To manually build polygons, here's what you should do:
// 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);
这篇关于建立使用XYZ三维曲面图与jzy3d坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!