I want to put cubes around the sphere surface like:
I'm using Java3D. I have a point of the sphere surface with:
double s = (random.nextInt(360));
double t = (random.nextInt(360));
double radius = 180;
double x = radius * Math.cos(s) * Math.sin(t);
double y = radius * Math.sin(s) * Math.sin(t);
double z = radius * Math.cos(t);
And I need put center of cube in this point and translate and rotate cubes like the figure. How can I do this?
I try rotate with s and t in different axes. But there is my result:
I need that the face of cube and the sphere surface are perpendicular like first image.
Simplest solution would be to do it in a sequence of 3 calls:
If you need to calculate such matrix for use by your program, you can follow glRotate & glTranslate specifications how do they modify current matrix and replicate their behaviour. Alternatively you can query GL matrix after these operations using glGetDoublev(GL_MODELVIEW_MATRIX);