-
-
Save jkwok91/37cee437d6c58a8c906d to your computer and use it in GitHub Desktop.
adapted from ex.14-10 from learning processing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
tetrahedron | |
*/ | |
float theta; | |
void setup() { | |
size(300,300,P3D); | |
background(0); | |
theta = 0; | |
} | |
void draw() { | |
background(0); | |
theta += 0.01; | |
translate(width/2,height/2); | |
rotateX(theta); | |
rotateY(theta); | |
drawShape(50); | |
} | |
void drawShape(int t) { | |
stroke(color(255,0,0)); | |
beginShape(TRIANGLES); | |
//base | |
vertex(-t*sin(PI/3),t,t*1/2); | |
vertex(t*sin(PI/3),t,t*1/2); | |
vertex(0,-t,t*1/2); | |
vertex(-t*sin(PI/3),t,t*1/2); | |
vertex(t*sin(PI/3),t,t*1/2); | |
vertex(0,0,-t); | |
vertex(t*sin(PI/3),t,t*1/2); | |
vertex(0,-t,t*1/2); | |
vertex(0,0,-t); | |
vertex(0,-t,t*1/2); | |
vertex(-t*sin(PI/3),t,t*1/2); | |
vertex(0,0,-t); | |
endShape(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment