// Jenny Zhang
// Section D
// jennyzha@andrew.cmu.edu
// Project 07
//http://mathworld.wolfram.com/Epitrochoid.html
function setup() {
createCanvas(480, 480);
}
function draw() {
background(255, 200, 200);
translate(width/2, height/2); // moving the drawing to center
drawEpitrochoid();
}
function drawEpitrochoid() {
var n = 1500;
noFill();
stroke(255);
var x;
var y;
var h = constrain(mouseX, 0, 480); //distance between radius of smaller circle to the curve drawn (contrained and varied between left and right borders)
var a = 300; //radius of bigger circle
var b = a/constrain(mouseY, 0, 480); //radius of smaller circle (constrained to the left and right borders)
beginShape();
for (var i=0; i < n; i++) {
var t = map(i, 0, n, 0, TWO_PI);
var x = (a + b) * cos(t) - h * cos (((a+ b)/b)*t); //epitrochoid equation
var y = (a + b) * sin(t) - h * sin (((a+ b)/b)*t); //epitrochoid equation
vertex(x, y);
}
endShape();
}
I really enjoyed playing around with all of the possible varying numbers in this project and am very pleased with the outcome. Moving your mouse very slowly throughout the canvas you’re able to see so many different beautiful designs made by the epitrochoid curves.