int side=35; int sx=side+1; int sy=side+1; int sz=side+1; int hsx=int(sx/2.0f); int hsy=int(sy/2.0f); int hsz=int(sz/2.0f); int nc=52; float[][][] points=new float[sx][sy][sz]; float[][] transDown=new float[sx][sz]; float[][] transUp=new float[sx][sz]; float[][] transLeft=new float[sy][sz]; float[][] transRight=new float[sy][sz]; float[][] transFront=new float[sx][sy]; float[][] transBack=new float[sx][sy]; int[][][] volumes=new int[nc][2][3]; float ct=0.5; float ay=0.50; float ry=0.005; float ax=0.2; float factor=1.0; float scx=300.0/sx; float scy=300.0/sy; float scz=300.0/sz; int count; boolean firstClick; void setup(){ size(600,500,P3D); noFill(); framerate(18); setupVolume(); } void draw(){ background(255); if (count<2.5*nc+1){ calculate(); } translate(300,240-ct*45,0); ax=0.9*ax+0.1*(-0.5+mouseY/600.0); rotateX(ax); ry=0.9*ry+0.1*(-0.005+mouseX/60000.0); rotateY(ay+=ry); factor=1.0; drawTrace(); drawTrans(); count++; } void mouseReleased(){ if (firstClick==false){ firstClick=true; } else{ ct*=-1; count=0; } } void keyReleased(){ setupVolume(); count=0; } void setupVolume(){ volumes[0][0][0]=1; volumes[0][1][0]= side; volumes[0][0][1]=side-1; volumes[0][1][1]= side; volumes[0][0][2]=1; volumes[0][1][2]= side; volumes[1][0][0]=1; volumes[1][1][0]= side; volumes[1][0][1]=1; volumes[1][1][1]= 2; volumes[1][0][2]=1; volumes[1][1][2]= side; for(int c=2; c0) transDown[i][k]+=points[i][j][k] ; if (points[i][j][k]<0) transUp[i][k]-=points[i][j][k] ; if (points[i][j][k]>0) transLeft[j][k]+=points[i][j][k] ; if (points[i][j][k]<0) transRight[j][k]-=points[i][j][k] ; if (points[i][j][k]>0) transFront[i][j]+=points[i][j][k] ; if (points[i][j][k]<0) transBack[i][j]-=points[i][j][k] ; } } } } void drawTrace(){ stroke(10,40); for(int k=1;k0){ beginShape(QUADS); for(int k=1;klimit2))||((value<=limit2)&&(value>limit1))); } float ruleOfThree(float x1, float x2, float x3, float y1, float y2){// if x1 maps to y1, and x2 maps to y2, find y3 linearly corresponding to x3 return(y1 + (y2-y1)/(x2-x1)*(x3-x1)); }