Curran Zhang- Project 07- Curves

sketch

function setup(){
	createCanvas(480,480);
}

function draw(){
	background(50);
	push();
	translate(width/2,height/2);
		push();
			for (var i = 0; i < width; i+=4) {
			translate(i,i)
			rotate(PI * mouseX/150);
			drawDevilCurve();
		};
		pop();
	pop();
}

function drawDevilCurve(){
	var range = 50;
	var b = map(mouseY, 50, height-50, 0, 50);
	var a = map(mouseX, 50, height-50, 0, 50);

	noFill();
	stroke(200);
	beginShape();
	for (var i = 0; i < range ; i++) {
		var t = map (i, 0, range, 0,  2* PI);
		var SINS = sq(sin(t));
		var COSS = sq(cos(t));
		var x = cos(t) * sqrt(((sq(a) * SINS) - (sq(b)*COSS)) / (SINS - COSS));
		var y = sin(t) * sqrt(((sq(a) * SINS) - (sq(b)*COSS)) / (SINS - COSS));
		vertex(x,y);
	}
	endShape();
}

For this project, I began with a Devil’s Curve. Upon its creation, I began playing around with the different parameters of the curve to find an interesting shape. The two parameters involving the location of the mouse includes the different shape that the function would create and the location in which the curves would spiral.

http://mathworld.wolfram.com/DevilsCurve.html

Leave a Reply