xxxxxxxxxx
// Equations from http://oolong.co.uk/Trochor.htm (Fergus Crawshay(Ray) Murray)
// sin, cos, frameCount, TWO_PI, vertex, phase
// no interaction
// bit of a mess in Java mode.
int numPoints = 300;
float incr = TWO_PI/float(numPoints);
float R = 150;
float r = R/2.5;
float numTurns = 1;
float ratio = 2;
float phi = 0;
void setup() {
size(550, 550);
colorMode(HSB, 360, 100, 100);
noFill();
}
void draw() {
background(340);
translate(width/2, height/2);
phi = frameCount * .02;
stroke(#054B0D);
strokeWeight(20);
drawShape(0);
rotate(sin(frameCount * .05)*.07);
stroke(340);
strokeWeight(3);
drawShape(0);
//rotate(cos(frameCount * .005) * PI);
stroke(#054B0D);
strokeWeight(20);
drawShape(PI);
rotate(sin(frameCount * .05)*.07);
stroke(340);
strokeWeight(3);
drawShape(PI);
}
void drawShape(float a) {
beginShape();
for (float i = 0; i <= TWO_PI * numTurns; i += incr) {
float x = R * cos (i) + r * cos (ratio * i + (phi+a));
float y = R * sin (i) + r * sin (ratio * i - (phi+a));
vertex(x, y);
}
endShape();
}