0

I want to draw a cube using jMathPlot. The cube's points are:

(0,0,1),(1,0,1),(1,1,1),(0,1,1),(0,0,2),(1,0,2),(1,1,2),(0,1,2)

I have these variables:

double[] x = {0,1,0,1};
double[] y = {0,1,0,1};
double[][] z1 = {{1,1,2,2},
                 {2,2,1,1},
                 {1,1,2,2},
                 {1,1,2,2}};

Plot3DPanel plot = new Plot3DPanel("SOUTH");
plot.addGridPlot("cube", Color.red ,x, y, z1);

It doesn't work and honestly I still don't understand why z must be a 2D array?

Any help would be appreciated.

demongolem
  • 9,474
  • 36
  • 90
  • 105

1 Answers1

0

After investigating the source code for JMathPlot, I think Z is 2D array because Z's are given as the result of some function f(x,y). See GridPlotsExample on how to construct double[][] for z argument.