# Project 07 – Sean McGadden

## Project 07 Curves

This project was super interesting to make and play with. Some of the math involved with the manipulation of more complex curves eluded me a little. However, I found overlaying the Dumbbell Curve and Devil Curve to be really pleasing to spin around and mess with the sizing of them. This was a difficult assignment and I wish I could’ve para-metricized the curves more into a perspective or abstract three dimensional volumes. This project looks really flat and I think after more practice I would like to impose more perspective lines and curves that reach beyond the canvas in a more interesting composition.

The Dumbell Curves make nice looking clover shapes that have some hidden shapes behind it from the Devil’s Curve.

``````//Sean McGadden
//Project 07
//Section C

//Drawing Setup
function setup() {
createCanvas(640, 400);

}

//Chosing to call from curveX or curveY
function draw() {
background(160, 190, 255);
push();
translate(width / 2, height / 2);
drawCurve(false, false);
drawCurve(false, true);
drawCurve(true, true);
drawCurve(true, false);
pop();
}

//Drawing Dumbell Curve
//basic varible defintion and instantiation of Dumbell Curve
function drawCurve(isDumbell, isFlipped) {

var x;
var y;
var nPoints = 100;

var percX = mouseX / 640.0;
var percY = mouseY / 400.0;
rotate(TWO_PI * percY);

var a = 200.0 * percX;
var t

stroke("lightcyan");
fill("green");
beginShape();
for (var i = 0; i < nPoints; i++) {
var t = map(i, 0, nPoints, 0, TWO_PI);

x	=	curveX(isDumbell, a, t);
y	=	curveY(isDumbell, a, t);

if (isFlipped) {
var temp = x;
x = y;
y = temp;
}
vertex(x, y);
}
endShape(CLOSE);
}

//Returns x value of the desired curve
//Choosing between Dumbell Curve or the Devil's Curve based on a and t
//Devil's Curves uses thrid variable called b initialized below
function curveX(isDumbell, a, t) {
if(isDumbell){
return a * sin ( t);
} else {
var b = a / 2.0;
return cos(t) * sqrt(((a * a * sin(t) * sin(t))-(b * b * cos(t) * cos(t)))/((sin(t) * sin(t)) - (cos(t) * cos(t))));
}

}
//Returns y value of the desired curve
//Choosing between Dumbell Curve or the Devil's Curve based on a and t for the
//Devil's Curves uses thrid variable called b initialized below
function curveY(isDumbell, a, t) {
if(isDumbell){
return a * sin(t) * cos(t);
} else {
var b = a / 2.0;
return sin(t) * sqrt(((a * a * sin(t) * sin(t))-(b * b * cos(t) * cos(t)))/((sin(t) * sin(t)) - (cos(t) * cos(t))));
}
}``````