sketch
I was really intrigued by the hypotrochoid curve and how it was drawn the site itself. Through this project I was able to play around with the functions of cos and sin which I havent been able to delve into before. It was interesting to play with the numbers and see what different shapes appeared because of the repetitively drawn lines.
/* Nina Yoo
Section E
nyoo@andrew.cmu.edu
Project-07 Composition with Curves*/
var nPoints = 200
function setup() {
createCanvas(480, 480);
frameRate(15);
}
function draw() {
background(200,34,164);
push();
//into middle
translate(width/2, height/2);
drawHypotrochoidCurve();
pop();
}
function drawHypotrochoidCurve(){
//Hyptotrochoid
//Link: http://mathworld.wolfram.com/Hypotrochoid.html
var x;
var y;
var h = 15;
var a = map(mouseX, 0,width,100,300); // (wat u want to effect, orginal range, new range) makes the variables interactive
var b = map(mouseY, 0, height, 100,300);
stroke(210,36,117);
strokeWeight(2);
beginShape();
for(var i = 0; i <nPoints; i ++){
// set variable t within the for loop so it keeps on looping (this acts as the angle for mouse)
var t = map (i, 0, nPoints, 0 , 330 );
// equation for the curve
x = (a - b) * cos(t) + h * cos((a - b) * t);
y = (a - b) * sin(t) - h * sin((a - b) * t);
vertex(x,y); // setting the patternn in the middle
}
endShape(CLOSE);
}