Beast II


Mind / body













import peasy.*; PeasyCam cam; PVector[][]globe;
int total = 75; float m = 0; float mchange = 0; float a = 1; float b = 1;

void setup (){size(900, 900, P3D); cam = new PeasyCam(this, 500); colorMode(HSB); globe=new PVector [total+1[total+1];}

float supershape(float theta, float m, float n1, float n2, float n3) { float t1 = abs((1/a)*cos(m * theta / 4)); r1 = pow(t1,n2);
float t2 = abs((1/b)*sin(m * theta/4)); t2 = pow(t2, n3); float t3 = t1 + t2; float r = pow(t3, - 1 / n1);  return r; }

void draw (){ 
m = map(sin(mchange), -1, 0, 1, 2); mchange -= 0.01; background (0); noStroke(); lights (); float r = 200;
for (int i =0; i < total+1; i++) { float lat = map(i, 0, total, -HALF_PI, HALF_PI); float r2 = supershape(lat, 2, 0.1, 0.1, 1);
for (int j = 0; j < total+1; j++) { float lon = map(j, 0, total, -PI, PI); float r1 = supershape(lon, m, 0.5, 1, 0.3);
float x=r*r1*cos(lon)*r2*cos(lat); float y=r*r1*sin(lon)*r2*cos(lat); float z=r*r2*sin(lat); globe[i][j]=new PVector(x, y, z);}}

noStroke (); fill(255);
for (int i = 0; i < total; i++){ beginShape(TRIANGLE_STRIP); for (int j=0;j< total+1; j++){
PVector v1=globe[i][j]; vertex(v1.x, v1.y, v1.z); PVector v2 = globe[i+1][j]; vertex(v2.x, v2.y, v2.z);} endShape (); }}