import java.lang.Math; class PentaCube{ PVector[] vertices = new PVector[30]; float h, d; // Default constructor PentaCube(){ } // Constructor 2 PentaCube(float h, float d) { this.h = h; this.d = d; //front vertices[0] = new PVector(0, -h, d/2); vertices[1] = new PVector(-(float)(h*Math.cos(54)), (float)(h*Math.sin(54))+55, d/2); vertices[2] = new PVector((float)(h*Math.cos(18))-20, -(float)(h*Math.sin(18)), d/2); vertices[3] = new PVector(-(float)(h*Math.cos(18))+20, -(float)(h*Math.sin(18)), d/2); vertices[4] = new PVector((float)(h*Math.cos(54)), (float)(h*Math.sin(54))+55, d/2); //side1 vertices[5] = new PVector(0, -h, d/2); vertices[6] = new PVector(0, -h, -d/2); vertices[7] = new PVector(-(float)(h*Math.cos(54)), (float)(h*Math.sin(54))+55, -d/2); vertices[8] = new PVector(-(float)(h*Math.cos(54)), (float)(h*Math.sin(54))+55, d/2); //side2 vertices[9] = new PVector(-(float)(h*Math.cos(54)), (float)(h*Math.sin(54))+55, d/2); vertices[10] = new PVector(-(float)(h*Math.cos(54)), (float)(h*Math.sin(54))+55, -d/2); vertices[11] = new PVector((float)(h*Math.cos(18))-20, -(float)(h*Math.sin(18)), -d/2); vertices[12] = new PVector((float)(h*Math.cos(18))-20, -(float)(h*Math.sin(18)), d/2); //side3 vertices[13] = new PVector((float)(h*Math.cos(18))-20, -(float)(h*Math.sin(18)), d/2); vertices[14] = new PVector((float)(h*Math.cos(18))-20, -(float)(h*Math.sin(18)), -d/2); vertices[15] = new PVector(-(float)(h*Math.cos(18))+20, -(float)(h*Math.sin(18)), -d/2); vertices[16] = new PVector(-(float)(h*Math.cos(18))+20, -(float)(h*Math.sin(18)), d/2); //side4 vertices[17] = new PVector(-(float)(h*Math.cos(18))+20, -(float)(h*Math.sin(18)), d/2); vertices[18] = new PVector(-(float)(h*Math.cos(18))+20, -(float)(h*Math.sin(18)), -d/2); vertices[19] = new PVector((float)(h*Math.cos(54)), (float)(h*Math.sin(54))+55, -d/2); vertices[20] = new PVector((float)(h*Math.cos(54)), (float)(h*Math.sin(54))+55, d/2); //side5 vertices[21] = new PVector((float)(h*Math.cos(54)), (float)(h*Math.sin(54))+55, d/2); vertices[22] = new PVector((float)(h*Math.cos(54)), (float)(h*Math.sin(54))+55, -d/2); vertices[23] = new PVector(0, -h, -d/2); vertices[24] = new PVector(0, -h, d/2); //back vertices[25] = new PVector(0, -h, -d/2); vertices[26] = new PVector(-(float)(h*Math.cos(54)), (float)(h*Math.sin(54))+55, -d/2); vertices[27] = new PVector((float)(h*Math.cos(18))-20, -(float)(h*Math.sin(18)), -d/2); vertices[28] = new PVector(-(float)(h*Math.cos(18))+20, -(float)(h*Math.sin(18)), -d/2); vertices[29] = new PVector((float)(h*Math.cos(54)), (float)(h*Math.sin(54))+55, -d/2); //set Corners Corners[0] = vertices[0]; Corners[1] = vertices[1]; Corners[2] = vertices[2]; Corners[3] = vertices[3]; Corners[4] = vertices[4]; Corners[5] = vertices[6]; Corners[6] = vertices[7]; Corners[7] = vertices[11]; Corners[8] = vertices[15]; Corners[9] = vertices[19]; } void create(){ // Draw front and back pentagons beginShape(LINES); for(int j = 0; j < 5; j++){ if(j == 4){ vertex(vertices[j].x, vertices[j].y, vertices[j].z); vertex(vertices[0].x, vertices[0].y, vertices[0].z); }else{ vertex(vertices[j].x, vertices[j].y, vertices[j].z); vertex(vertices[j+1].x, vertices[j+1].y, vertices[j+1].z); } } for(int j = 25; j < 30; j++){ if(j == 29){ vertex(vertices[j].x, vertices[j].y, vertices[j].z); vertex(vertices[25].x, vertices[25].y, vertices[25].z); }else{ vertex(vertices[j].x, vertices[j].y, vertices[j].z); vertex(vertices[j+1].x, vertices[j+1].y, vertices[j+1].z); } } endShape(); // Draw sides for(int j = 0; j < 5; j++){ beginShape(QUADS); for(int k = 0; k < 4; k++){ vertex(vertices[5+4*j+k].x, vertices[5+4*j+k].y, vertices[5+4*j+k].z); // vertex(vertices[9+k].x, vertices[9+k].y, vertices[9+k].z); } endShape(); } } }