We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOpenGL and 3D Libraries › 3D scattter plot using processing
Page Index Toggle Pages: 1
3D scattter plot using processing (Read 1115 times)
3D scattter plot using processing
Apr 20th, 2006, 3:20pm
 
Hello,
Is it possible to create a 3-D scatter plot using processing P3D? I have looked at the rotating cube example, and was very enthused.
I need to make that cube "grided", (its solid now) , put values on each x,y,z axis and then be able to put a spherical object (the actual plot) on any given x,y,z coordinate position.
Any suggestions are welcome.
regards
Sameer
Re: 3D scattter plot using processing
Reply #1 - May 11th, 2006, 1:14am
 
Use a loop to draw an axis using line();

 // This will draw a set of X axis
 pushMatrix();
 translate(0, y_min, z_min);
 float x_step = (x_max-x_min)/(number_of_grid_lines-1);
 float y_step = (y_max-y_min)/(number_of_grid_lines-1);
 float z_step = (z_max-z_min)/(number_of_grid_lines-1);
 for(int i=0; i<number_of_grid_lines; i++)
 {
   pushMatrix();
   for(int j=0; j<number_of_grid_lines; j++)
   {
     line(x_min, 0, 0, x_max, 0, 0);
     translate(0, y_step, 0);
   }
   popMatrix();
   translate(0, 0, z_step);
 }
 popMatrix();  


The above draws a set of x-axis ... modify accordingly to make the y and the z. (its also very rudimentary, with no auto-scaling or major/minor grid lines). As for drawing a sphere at a spot, simply translate to that point and make a sphere for each of your data points:

pushMatrix();
translate(point_x, point_y, point_z);
sphere(radius);
popMatrix();
Page Index Toggle Pages: 1