//sketch_3D_STD_01 パイプクランプ 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.1); fill(255, 255, 255); scale(2,2,2); STD_01(120,30,20,30,90,38.2,7);//STD_01)パイプクランプ } //STD_01)パイプクランプ void STD_01(float L1,float L2,float L3,float L4,float L5,float R,float r) { int An=8; int Pn=An+6;//ポイント数 float[] X=new float[Pn]; float[] Z=new float[Pn]; int i; float dA=2*acos(L4/R)/An;; //float AA=dA*4; for(i=0;i<= An;i++) { float angle = (i-An/2)*dA; X[i]=R*sin(angle);Z[i]=R*cos(angle); } X[An+1]=L1/2;Z[An+1]=L4; X[An+2]=L1/2;Z[An+2]=L4+L3; X[An+3]=-L1/2;Z[An+3]=L4+L3; X[An+4]=-L1/2;Z[An+4]=L4; X[An+5]=X[0];Z[An+5]=Z[0]; Y_Side(An+1,X,Z,L2);//側面 int Pn2=5;//ポイント数 float[] X2=new float[Pn2]; float[] Y2=new float[Pn2]; float[] Z2=new float[Pn2]; int Pn3=17;//ポイント数 float[] X3=new float[Pn3]; float[] Y3=new float[Pn3]; for(i=0;i= 0; i--) { vertex(X[i],Y[i]); } } void Z_Polyon_MZ(int Pn,float X[],float Y[],float Z)//多角形時計回り { int i; for (i = Pn-1; i >= 0; i--) { vertex(X[i],Y[i],Z); } }