float R,r,d; float theta,dtheta; float x,y,xo,yo; void setup() { size(400,400); framerate(60); smooth(); background(127); strokeWeight(3); theta = 0.0; dtheta = 0.1; R = 43; // radius of outer fixed circle r = 13; // radius of inner rolling circle d = 15; // distance from center of rolling circle x = (R-r)*cos(theta) + d*cos( ((R-r)/r)*theta ); y = (R-r)*sin(theta) - d*sin( ((R-r)/r)*theta ); theta %= TWO_PI; } void draw() { translate(width/2,height/2); scale(3.0); stroke(200-(theta%100),0, 127 + (theta % 127)); xo = x; yo = y; x = (R-r)*cos(theta) + d*cos( ((R-r)/r)*theta ); y = (R-r)*sin(theta) - d*sin( ((R-r)/r)*theta ); line( x,y, xo,yo ); // println("dx:"+(x-xo)+", dy:"+(y-yo)); theta += dtheta; d += random(-0.5,0.5); }