annotate yetilab/plot/plot.yeti @ 117:098b4efde5b1

Some debug
author Chris Cannam
date Thu, 18 Apr 2013 09:46:34 +0100
parents 30c790d2789e
children ae802edb0561 789da8e322e1
rev   line source
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@117 17 result = matrix.getAt y x;
Chris@117 18 println "f(\(x),\(y)) -> \(result)";
Chris@117 19 result
Chris@108 20 end;
Chris@108 21 new MMapper());
Chris@108 22
Chris@108 23 newMatrixLogMapper matrix =
Chris@108 24 (class MMapper extends Mapper
Chris@108 25 double f(double x, double y)
Chris@108 26 ln (matrix.getAt y x)
Chris@108 27 end;
Chris@108 28 new MMapper());
Chris@108 29
Chris@108 30 newMapper mapFunction =
Chris@108 31 (class FMapper extends Mapper
Chris@108 32 double f(double x, double y)
Chris@108 33 mapFunction x y
Chris@108 34 end;
Chris@108 35 new FMapper());
Chris@108 36
Chris@115 37 plotMatrix matrix =
Chris@117 38 (mapper = newMatrixMapper matrix;
Chris@108 39 size = matrix.size;
Chris@108 40 xrange = new Range(1, size.columns - 1);
Chris@108 41 yrange = new Range(1, size.rows - 1);
Chris@108 42 grid = new OrthonormalGrid(xrange, size.columns, yrange, size.rows);
Chris@112 43 println "Matrix size: \(size)";
Chris@117 44 surface = Builder#buildOrthonormal(grid, mapper); //??? big?
Chris@117 45 println "Z Bounds: \(surface#getBounds()#getZmin()) -> \(surface#getBounds()#getZmax())";
Chris@111 46 surface#setFaceDisplayed(false);
Chris@108 47 surface#setWireframeDisplayed(true);
Chris@108 48 surface#setWireframeColor(Color#BLACK);
Chris@112 49 // chart = new Chart(Quality#Fastest, "swing");
Chris@112 50 chart = new Chart(Quality#Nicest);
Chris@108 51 chart#getScene()#getGraph()#add(surface);
Chris@115 52 ChartLauncher#openChart(chart);
Chris@115 53 ());
Chris@108 54
Chris@110 55 plotStructure structure =
Chris@110 56 case structure of
Chris@110 57 Grid matrix:
Chris@115 58 plotMatrix matrix;
Chris@110 59 //!!!
Chris@110 60 _: failWith "Cannot plot this structure (only grids implemented so far)";
Chris@110 61 esac;
Chris@108 62
Chris@115 63 {
Chris@115 64 plotMatrix,
Chris@115 65 plotStructure
Chris@115 66 }
Chris@110 67