Rotating and drawing an ellipse onto a sphere
in
Programming Questions
•
1 year ago
I am trying to plot some spherical marks onto a sphere. Here is a screenshot:
The little black spheres are being drawn with the following code:
- // Ellipse
- fill(0);
- noStroke();
- pushMatrix();
- translate(x, y, z);
- beginShape(TRIANGLE_STRIP);
- for(float t=0; t<TWO_PI; t+=TWO_PI/12) {
- fill(0,255);
- vertex(0,0);
- fill(0,0);
- vertex(4*cos(t),4*sin(t));
- }
- endShape();
- popMatrix();
The problem I am having is that the shapes are rotated at random angles and are not facing outwards from the point they are drawn at. I want them to be rotated so that they act like points on the sphere.
Can anyone tell me what I am doing wrong?
1