Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android 3D Surface Plot

My requirement is to create a 3d surface plot(should also display the x y z axis) from a list of data points (x y z) values.The 3d visualization should be done on ANDROID.

My Inputs : Currently planning on using open gl 1.0 and java. I m also considering Adore3d , min3d and rgl package which uses open gl 1.0. Good at java ,but a novice at 3d programming.
Time Frame : 2 months

I would like to know the best way to go about it? Is opengl 1.0 good for 3d surface plotting?Any other packages/libraries that can be used with Android?

like image 490
MRSGT _GT Avatar asked Jan 21 '12 04:01

MRSGT _GT


People also ask

What is a 3D surface plot?

Introduction. Surface plots are diagrams of three-dimensional data. Rather than showing the individual data points, surface plots show a functional relationship between a designated dependent variable (Y), and two independent variables (X and Z). The plot is a companion plot to the contour plot.

When would you use a 3D surface plot?

Use a 3D surface plot to see how a response variable relates to two predictor variables. A 3D surface plot is a three-dimensional graph that is useful for investigating desirable response values and operating conditions.

Can you make a 3D plot in Excel?

3D plots are, also known as surface plots in Excel, used to represent three-dimensional data. To create a three-dimensional plot in Excel, we need to have a three-dimensional range of data which means we must have three-axis – X, Y, and Z. The 3D plots or surface plots can be used from the insert tab in Excel.


1 Answers

Well, you can plot the surface using OpenGL 1.0 or OpenGL 2.0. All you need to do is to draw the axes as lines and draw the surface as triangles. If you have your heightfield data, you would do:

float[][] surface;
int width, height; // 2D surface data and it's dimensions

GL.glBegin(GL.GL_LINES);
GL.glVertex3f(0, 0, 0); // line starting at 0, 0, 0
GL.glVertex3f(width, 0, 0); // line ending at width, 0, 0
GL.glVertex3f(0, 0, 0); // line starting at 0, 0, 0
GL.glVertex3f(0, 0, height); // line ending at 0, 0, height
GL.glVertex3f(0, 0, 0); // line starting at 0, 0, 0
GL.glVertex3f(0, 50, 0); // line ending at 0, 50, 0 (50 is maximal value in surface[])
GL.glEnd();
// display the axes

GL.glBegin(GL.GL_TRIANGLES);
for(int x = 1; x < width; ++ x) {
    for(int y = 1; y < height; ++ y) {
        float a = surface[x - 1][y - 1];
        float b = surface[x][y - 1];
        float c = surface[x][y];
        float d = surface[x - 1][y];
        // get four points on the surface (they form a quad)

        GL.glVertex3f(x - 1, a, y - 1);
        GL.glVertex3f(x, b, y - 1);
        GL.glVertex3f(x, c, y);
        // draw triangle abc

        GL.glVertex3f(x - 1, a, y - 1);
        GL.glVertex3f(x, c, y);
        GL.glVertex3f(x - 1, d, y);
        // draw triangle acd
    }
}
GL.glEnd();
// display the data

This draws simple axes and heightfield, all in white color. It should be pretty straight forward to extend it from here.

like image 105
the swine Avatar answered Sep 24 '22 09:09

the swine