当前位置: 首页 > 工具软件 > Jzy3D > 使用案例 >

画三维曲面图 java_使用Jzy3d绘制散点和曲面图

姚昊焱
2023-12-01

import java.util.ArrayList;

import java.util.List;

import org.jzy3d.chart.Chart;

import org.jzy3d.chart.ChartLauncher;

import org.jzy3d.colors.Color;

import org.jzy3d.colors.ColorMapper;

import org.jzy3d.colors.colormaps.ColorMapRainbow;

import org.jzy3d.maths.Coord3d;

import org.jzy3d.plot3d.builder.Builder;

import org.jzy3d.plot3d.primitives.MultiColorScatter;

import org.jzy3d.plot3d.primitives.Shape;

import org.jzy3d.plot3d.rendering.canvas.Quality;

public class Jzy3dPlot4 {

public static void main(String[] args) {

int size = 1000;

double x, y, z;

List lista = new ArrayList();

for (int i = 0; i < size; i++) {

x = (float) Math.random() - 0.5f;

y = (float) Math.random() - 0.5f;

z = (float) Math.random() - 0.5f;

lista.add(new Coord3d(x, y, z));

}

// Create surface 曲面

Shape surface = Builder.buildDelaunay(lista);

surface.setColorMapper(new ColorMapper(new ColorMapRainbow(),

surface.getBounds().getZmin(),

surface.getBounds().getZmax(), new Color(1, 1, 1,

.5f)));

surface.setFaceDisplayed(true);

surface.setWireframeDisplayed(false);

surface.setWireframeColor(Color.BLACK);

Chart chart = new Chart(Quality.Advanced);

chart.getScene().getGraph().add(surface);

ChartLauncher.openChart(chart);

Coord3d[] points = new Coord3d[size];

lista.toArray(points);

// Create scatter 散点

MultiColorScatter scatter = new MultiColorScatter(points, new

ColorMapper(new ColorMapRainbow(), -0.5f, 0.5f));

chart = new Chart();

chart.getAxeLayout().setMainColor(Color.WHITE);

chart.getView().setBackgroundColor(Color.BLACK);

chart.getScene().add(scatter);

ChartLauncher.openChart(chart);

}

}

 类似资料: