//sketch_3D_U_Bolt void setup() { size(400, 400, P3D); } void draw() { background(255, 255, 255); lights(); ortho(-width/2, width/2, -height/2, height/2); // Same as ortho() translate(width / 2, height / 2); rotateY(map(mouseX, 0, width, -PI/1, PI/1)); rotateX(map(mouseY, 0, height, PI/1, -PI/1)); //noStroke(); strokeWeight(0.5); fill(255, 255, 255); scale(1, 1,1); U_Bolt(6,45,68);//Uボルト } void U_Bolt(float r,float R,float H)//Uボルト { int sides=16;//分割数 int SnR=16;//面数 float[][] X=new float[SnR+1][sides+1]; float[][] Y=new float[SnR+1][sides+1]; float[][] Z=new float[SnR+1][sides+1]; int i,j; for(j=0;j<=SnR;j++) { float Aj=j*PI/SnR; for(i=0;i<=sides;i++) { float Ai=i*2*PI/sides; X[j][i]=(R+r*cos(Ai))*cos(Aj); Y[j][i]=r*sin(Ai); Z[j][i]=(R+r*cos(Ai))*sin(Aj); } } for(j=0;j