Created
October 29, 2014 02:27
-
-
Save joselynNeon/da1160e9ca88e77f1003 to your computer and use it in GitHub Desktop.
double_square_helix
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
Planet p, p2, c, c2, d, d2, g, g2, e, e2; | |
void setup(){ | |
size(1024, 768, P3D); | |
// have to do all the openGL stuff on the main thread | |
e = new Planet(50, 150, PI/20, -250); | |
e2 = new Planet(50, -150, PI/20, -250); | |
g = new Planet(50, 150, PI/22, -100); | |
g2 = new Planet(50, -150, PI/22, -100); | |
p = new Planet(50, 150, PI/24, 50); | |
p2 = new Planet(50, -150, PI/24, 50); | |
c = new Planet(50, 150, PI/26, 200); | |
c2 = new Planet(50, -150, PI/26, 200); | |
d = new Planet(50, 150, PI/28, 350); | |
d2 = new Planet(50, -150, PI/28, 350); | |
} | |
void draw(){ | |
background(0); | |
noStroke(); | |
lights(); | |
translate(width/2, height/2); | |
p.draw(); p2.draw(); | |
c.draw(); c2.draw(); | |
d.draw(); d2.draw(); | |
g.draw(); g2.draw(); | |
e.draw(); e2.draw(); | |
} | |
public class Planet{ | |
int size, orbitSize; | |
float rotation = 0, rotationRate, start; | |
public Planet(int size, int orbitSize, float rotationRate, int start){ | |
this.size = size; | |
this.orbitSize = orbitSize; | |
this.rotationRate = rotationRate; | |
this.start=start; | |
} | |
//nested push and pop matrices can be used here | |
public void draw(){ | |
pushMatrix(); | |
rotateY(rotation); | |
translate(orbitSize, start); | |
box(size); | |
popMatrix(); | |
rotation = (rotation + rotationRate) % (2 * PI); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment