float[] x = new float[12]; float[] y = new float[12]; float[] z = new float[12]; PFont font; float rotX=0,rotY=0; //for animating rotation void setup() { size(500,500,P3D); font = loadFont("AachenBT-Roman-48.vlw"); textFont(font); //build table for (int i=0; i<12; i++) { if (i==0) { x[i]=0; y[i]=0; z[i]=.5*sqrt(5.0); } if (i>=1 && i<=5) { x[i]=cos((i-1)*2*PI/5); y[i]=sin((i-1)*2*PI/5); z[i]=.5; } if (i>=6 && i<=10) { x[i]=cos(PI/5+(i-6)*2*PI/5); y[i]=sin(PI/5+(i-6)*2*PI/5); z[i]=-.5; } if (i==11) { x[i]=0; y[i]=0; z[i]=-.5*sqrt(5.0); } //normalize float r = sqrt(x[i]*x[i]+y[i]*y[i]+z[i]*z[i]); x[i] = x[i]/r; y[i] = y[i]/r; z[i] = z[i]/r; } } void draw() { background(128,128,100); translate(width/2, height/2, -30); //rotation float deltaX = rotX - mouseX/float(width) * TWO_PI; float deltaY = rotY - mouseY/float(height) * TWO_PI; if (abs(deltaX)>.01) rotX -= deltaX/4; if (abs(deltaY)>.01) rotY -= deltaY/4; rotateX(-rotY); rotateY(-rotX); float r=150; //drawing Icosahedra for (int i=0; i<12; i++) { text(i,r*x[i],r*y[i],r*z[i]); } //next step is to connect the right nodes to each other... //see: http://www.science.gmu.edu/~nahmad/globgen/ }