Chris@108
|
1 module yetilab.plot.plot;
|
Chris@108
|
2
|
Chris@108
|
3 import org.jzy3d.plot3d.builder: Mapper;
|
Chris@108
|
4 import org.jzy3d.maths: Range;
|
Chris@108
|
5 import org.jzy3d.plot3d.primitives: Shape;
|
Chris@108
|
6 import org.jzy3d.chart: Chart, ChartLauncher;
|
Chris@108
|
7 import org.jzy3d.plot3d.builder: Builder;
|
Chris@108
|
8 import org.jzy3d.plot3d.builder.concrete: OrthonormalGrid;
|
Chris@108
|
9 import org.jzy3d.colors.colormaps: ColorMapRainbow;
|
Chris@108
|
10 import org.jzy3d.colors: ColorMapper;
|
Chris@108
|
11 import org.jzy3d.colors: Color;
|
Chris@108
|
12 import org.jzy3d.plot3d.rendering.canvas: Quality;
|
Chris@108
|
13
|
Chris@108
|
14 newMatrixMapper matrix =
|
Chris@108
|
15 (class MMapper extends Mapper
|
Chris@108
|
16 double f(double x, double y)
|
Chris@108
|
17 matrix.getAt y x
|
Chris@108
|
18 end;
|
Chris@108
|
19 new MMapper());
|
Chris@108
|
20
|
Chris@108
|
21 newMatrixLogMapper matrix =
|
Chris@108
|
22 (class MMapper extends Mapper
|
Chris@108
|
23 double f(double x, double y)
|
Chris@108
|
24 ln (matrix.getAt y x)
|
Chris@108
|
25 end;
|
Chris@108
|
26 new MMapper());
|
Chris@108
|
27
|
Chris@108
|
28 newMapper mapFunction =
|
Chris@108
|
29 (class FMapper extends Mapper
|
Chris@108
|
30 double f(double x, double y)
|
Chris@108
|
31 mapFunction x y
|
Chris@108
|
32 end;
|
Chris@108
|
33 new FMapper());
|
Chris@108
|
34
|
Chris@108
|
35 plot matrix =
|
Chris@108
|
36 (mapper = newMatrixLogMapper matrix;
|
Chris@108
|
37 size = matrix.size;
|
Chris@108
|
38 xrange = new Range(1, size.columns - 1);
|
Chris@108
|
39 yrange = new Range(1, size.rows - 1);
|
Chris@108
|
40 grid = new OrthonormalGrid(xrange, size.columns, yrange, size.rows);
|
Chris@112
|
41 println "Matrix size: \(size)";
|
Chris@110
|
42 surface = Builder#buildOrthonormalBig(grid, mapper); //??? big?
|
Chris@111
|
43 surface#setFaceDisplayed(false);
|
Chris@108
|
44 surface#setWireframeDisplayed(true);
|
Chris@108
|
45 surface#setWireframeColor(Color#BLACK);
|
Chris@112
|
46 // chart = new Chart(Quality#Fastest, "swing");
|
Chris@112
|
47 chart = new Chart(Quality#Nicest);
|
Chris@108
|
48 chart#getScene()#getGraph()#add(surface);
|
Chris@108
|
49 ChartLauncher#openChart(chart));
|
Chris@108
|
50
|
Chris@110
|
51 plotStructure structure =
|
Chris@110
|
52 case structure of
|
Chris@110
|
53 Grid matrix:
|
Chris@110
|
54 plot matrix;
|
Chris@110
|
55 //!!!
|
Chris@110
|
56 _: failWith "Cannot plot this structure (only grids implemented so far)";
|
Chris@110
|
57 esac;
|
Chris@108
|
58
|
Chris@110
|
59 { plot, plotStructure }
|
Chris@110
|
60
|