orientation around a sphere
in
Programming Questions
•
2 years ago
hi people,
I have a problem with rotations of ellipses around a sphere. I place my dots and ellipse in 3D like this:
anyone got an idea ?
thx
I have a problem with rotations of ellipses around a sphere. I place my dots and ellipse in 3D like this:
- import processing.opengl.*;
- int canvasX = 250;
- int canvasY = canvasX;
- int canvasZ = canvasX;
- int dots = 500;
- int radius = 150;
- float[] posX = new float[dots];
- float[] posY = new float[dots];
- float[] posZ = new float[dots];
- void setup() {
- size(500,500, OPENGL);
- frameRate(30);
- background(0);
- smooth();
- }
- void draw() {
- noFill();
- stroke(255);
- translate(canvasX/2, canvasY/2);
- for (int i = 0; i < dots; i++) {
- float phi = posX[i]*TWO_PI;
- float theta = PI - posY[i]*PI;
- posX[i] = radius*sin(theta)*cos(phi)+canvasX/2;
- posY[i] = radius*sin(theta)*sin(phi)+canvasY/2;
- posZ[i] = radius*cos(theta)+canvasZ/2;
- point(posX[i], posY[i],posZ[i]);
- pushMatrix();
- translate(posX[i], posY[i],posZ[i]);
- //rotateX(???);
- //rotateY(???);
- ellipse(0,0,10,10);
- popMatrix();
- }
- }
anyone got an idea ?
thx
1