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 › Position a sphere in 3d space
Page Index Toggle Pages: 1
Position a sphere in 3d space (Read 654 times)
Position a sphere in 3d space
Mar 3rd, 2009, 7:00pm
 
What is the best way to position a sphere in 3d space?  Lines give you a nice x,y,z - 2d objects give you an x,y - but spheres... just radius.  

So I've been using a transform, along with pop,push matrix.  Is this the best way to do this.

 stroke(126, 50);
 line(0, 0, 0, 100, 0, 0);
 line(0, 0, 0, 0, 100, 0);
 line(0, 0, 0, 0, 0, 100);
 noStroke();
 translate(0, 0, 0);
 fill(255, 0, 160, 50);
 sphere(10);
 sphereDetail(20);
 pushMatrix();
 translate(100,0,0);
 sphere(10);
 popMatrix();
 pushMatrix();
 translate(0,100,0);
 sphere(10);
 popMatrix();
 translate(0,0,100);
 sphere(10);
Re: Position a sphere in 3d space
Reply #1 - Mar 3rd, 2009, 9:14pm
 
Yup, translate combined with push/popMatrix is the way to do it.
Page Index Toggle Pages: 1