/* data visualization for sesnon
by nick lally
*/
int numOrbs = 3;
Time time;
Orbs[] orbs = new Orbs[numOrbs];
float x = 400;
float y = 100;
void setup() {
size(800, 800);
smooth();
background(255);
noStroke();
//initialize orbs
for (int i = 0; i < numOrbs; i++) {
orbs[i] = new Orbs(i*200, i*400, i+3, i*20, i*5+50, i*10+50);
}
//initialize time
time = new Time(width/2, 0, 50);
}
void draw() {
time.move();
}
class Time {
float x,y;
float radius;
//constructor
Time(float xpos, float ypos, float r) {
x = xpos;
y = ypos;
radius = r;
}
void move() {
fill(0, 1);
ellipse(x, y, 25, 25);
x = x + random(-.2,.2);
y = y + random(.2);
for (int i = 0; i < numOrbs; i++){
orbs[i].move(x,y);
}
}
}
class Orbs {
float x,y;
float radius;
float theta;
float speedX, speedY;
//constructor
Orbs(float xpos, float ypos, float r, float t, float sx, float sy) {
x = xpos;
y = ypos;
radius = r;
theta = t;
speedX = sx;
speedY = sy;
}
void move(float xpos, float ypos) {
x = xpos;
y = ypos;
theta += PI/100;
if (theta > TWO_PI) theta -= TWO_PI;
stroke(100,100);
ellipse(x + sin(theta)*speedX, y + tan(theta)*speedY, 1, 1);
noStroke();
speedX += random(-1,1);
}
}