Skip to content

Instantly share code, notes, and snippets.

@jkwok91
Created April 17, 2014 04:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jkwok91/37cee437d6c58a8c906d to your computer and use it in GitHub Desktop.
Save jkwok91/37cee437d6c58a8c906d to your computer and use it in GitHub Desktop.
adapted from ex.14-10 from learning processing
/*
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