Kristine Kim – Project 07 – Curves

sketch

//Kristine Kim
//Section D
//younsook@andrew.cmu.edu
//Project- 07- Curves
var nPoints = 70

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

function draw() {
    background(67, 42, 135);
    //calling all the functions 
    //drawing all of them on the center of the canvas

    push();
    translate(width/2, height/2);
    drawMovinglines();
    drawHypotrochoid();
    drawEpitrochoidCurve();   
    pop();
}

/*drawing the EpitrochoidCurve filled with
colors that are determined by mouseX and mouseY */
//the image that is drawing on top of everything
function drawEpitrochoidCurve(){

    var x;
    var y;

    var r1 = 100
    var r2 = r1 / mouseX;
    var h = constrain(mouseX, r1 , r2) 
    noStroke();
    fill(mouseY, 245, mouseX);
    beginShape();
    //for loop to draw the epitrochoidcurve
    for (var i = 0; i < nPoints; i++){
        var t = map(i, 0, nPoints, 0, TWO_PI);
        x = (r1 + r2) * cos(t) - h * cos(t * (r1 + r2) / r2);
        y = (r1 + r2) * sin(t) - h * sin(t * (r1 + r2) / r2);
        vertex (x,y);
    }
    endShape(CLOSE);
}
/*drawing the hypotrochoid with vertexs with
colors determined by mouseY */
//the first layer, drawing behind the epitrochoidcurve and movinglines

function drawHypotrochoid(){
    var x;
    var y;

    var r1 = 250
    var r2 = r1/ mouseX;
    var h = constrain(mouseY, r1, r2)
    stroke(mouseY, 200, 73);
    noFill();
    beginShape();
    //for loop for drawing the hypotrochoid form
    for (var i = 0; i < nPoints; i ++){
        var t = map(i, 0, nPoints, 0 , TWO_PI);
        x = (r1- r2) * cos(t) + h * cos(t * (r1 - r2) / r2);
        y = (r1- r2) * sin(t) + h * sin(t * (r1 - r2) / r2);
        vertex(x,y)
    }
    endShape(CLOSE);
}
/*drawing the constiently moving/wiggling circle
the radius and fill all controlled by mouseX and mouseY
the second layer, between the epitrochoidcurve and hypotrochoid */

function drawMovinglines(){
    var x;
    var y;
    var r1 = mouseX
    fill(mouseX, mouseY, mouseX)

    beginShape();
    //for loop for drawing the wiggling circle
    for (var i = 0; i < nPoints; i++) {
        var t = map(i, 0, nPoints, 0, TWO_PI);
        var x = r1 * cos(t);
        var y = r1 * sin(t);
        vertex(x + random(-5, 5), y + random(-5, 5));
    }
    endShape(CLOSE);

}
    

I was first very intimidated by this project because it looked so complicated and intricate, but I studying the website provided to us was very helpful. The little explanations and gif helped me understand the concept a lot. There are just so many ways we can execute this project so I struggled with starting the project, but once I drew the Hypotrochoid function, I knew how to approach this project. I played around with the quantity of nPoints, fill(), stroke(), and a lot with mouseX and mouseY until I ended up with the product that I have right now . I enjoyed creating this a lot because I love discovering new images and findings so I was pleasantly surprised every single time I changed something in my code and found different drawings.

Gretchen Kupferschmid-Looking Outwards-07

an example of a data visualization generated by Halo representing various data

Created by Ora Systems, the project “Halo” is a visualization platform that can combine up to ten different data sets into a fluid multi-dimensional band of light. Ora currently works to develop “halo”s that represent patient’s health status, working with health companies such as Mayo Clinic to enhance the way we look at the health data of patients by creating responsive wearable-driven health identities through an app. Through familiarizing yourself with the visualization, the user should be able to easily understand and compare vast data sets. I appreciate the way this project combines both a creative and artistic approach to the output of the visualization with a technical advancement in its combination of so many different data inputs/sets. I also appreciate that this project can be used to solve problems through its design and not just be a visual.

reated by Ora Systems, the project “Halo” is a visualization platform that can combine up to ten different data sets into a fluid multi-dimensional band of light. Ora currently works to develop “halo”s that represent patient’s health status, working with health companies such as Mayo Clinic to enhance the way we look at the health data of patients by creating responsive wearable-driven health identities through an app. Through familiarizing yourself with the visualization, the user should be able to easily understand and compare vast data sets. I appreciate the way this project combines both a creative and artistic approach to the output of the visualization with a technical advancement in its combination of so many different data inputs/sets. I also appreciate that this project can be used to solve problems through its design and not just be a visual.

Lauren Park – Project – 07 – Curves

sketch

//Lauren Park
//ljpark@andrew.cmu.edu
//Section D
//Project-07-Curves

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

function draw() {
  background(10);
  
  drawHypotrochoid();
  drawHypocycloid();
}

function drawHypotrochoid() {
  var x;
  var y;
  
  //mouse controls color change for stroke
  var r = constrain(mouseX, 0, 300);
  var g = constrain(mouseY, 0, 300);
  var b = 150;
  
  push();
  fill('#53E9FF');
  stroke(r, g, b);
  strokeWeight(3);
  translate(width/2, height/2);
  
  //control hypotrochoid
  var ha1 = map(r, 0, width, 0, 100);
  var ha2 = map(g, 0, height, 0, 100);
  
  beginShape();
  for (var i = 0; i < 480; i+=3) {
    var angle1 = map(i, 0, 250, 0, 360);
  
  //equation of hypotrochoid from MathWorld curves site
  x = (ha1 - ha2)* cos(angle1) + b * cos((ha1 - ha2 * angle1));
  y = (ha1 - ha2)* sin(angle1) - b * sin((ha1 - ha2 * angle1));
  vertex(x, y);
  }
  endShape();
  pop();
}

function drawHypocycloid() {
  var x;
  var y;
  
  //mouse controls color change for stroke
  var r = map(mouseX, 0, width, 50, 255);
  var g = map(mouseY, 0, height, 50, 255);
  
  push();
  fill(254, 193, 255, 140);
  stroke(r, g, 255);
  strokeWeight(0.3);
  translate(width/2, height/2);
  
  //control hypocycloid
  var hy1 = map(mouseX, 0, width, 0, 300);
  var hy2 = map(mouseY, 0, height, 0, 300);
  
  beginShape();
  for (var a = 0; a < 200; a+=3) {
    var angle2 = map(a, 0, 100, 0, 360);
    
    //equation of hypocycloid from MathWorld curves site
    x = (hy1 + hy2)* cos(angle2) + hy2* cos((hy1 + hy2)*angle2);
    y = (hy1 + hy2)* sin(angle2) - hy2* sin((hy1 + hy2)*angle2);
    vertex(x, y);
  }
  endShape();
  pop();
}

My idea for this project initially came from visuals of a rotating flower. However, throughout this process of figuring out this project, I became more interested in intricate patterns within this flower shape. And so, I was more focused on adding different color changes and perspectives when the mouse moves, to show off different designs of this form. When the mouse is somewhere near the top left edge of the canvas, I want to show the two different curves separately to represent seed-like forms, so that when the mouse moves in other directions, then the flower can gradually grow and spread to a wider view. Overall, it was very challenging but very satisfying to create patterns that remind of the kaleidoscope effect.

Lauren Park – Looking Outwards – 07

Artist Aaron Koblin visualized using bright colors and overlapping shapes to mark the many different pathways across North America by air travel. This project was originally developed by Scott Hessels and Gabriel Dunne for a project called “Celestial Mechanics” and uses data from the US Federal Aviation Administration (FAA) to help track these planes. This piece conceptualizes these pathways for over a 24 hour period.

I enjoy the visuals of this time-lapse animation piece because these colorful routes remind me of fireworks and show where each route starts and ends. It also paints a bigger picture for me to see how much the US relies on planes and how many airports we have. With the data collected from the FAA, the information was translated into these visuals through an open source programming called Processing.

The artist was highly successful in effectively displaying and color coding flights depending on each different type of flight. In contrast with the dark background, these bright colors also depict the relationship between humans and the technology we rely on. The way these pathways all come together to form a broad shape of the US is really powerful in communicating to viewers that we are systematically a part of this process of air travel.

“Flight Pattern” time-lapse animation (2005) by Aaron Koblin

Gretchen Kupferschmid-Project 07- Curves

sketch

//Gretchen Kupferschmid
//Section E
//gkupfers@andrew.cmu.edu
//Project-07-Curves

function setup() {
    createCanvas(480,480);
}
 function draw (){
    //gradient picking color
    var gradient1 = color(255, 238, 87); 
    var gradient2 = color(247, 119, 179); 
    createGradient(gradient1, gradient2);
    
    push();
    //moves all objects to center of canvas
    translate(width/2, height/2);
    //rotates shapes with movement of mouse X value from values 0 to pi
    rotate (map(mouseX, 0, width, 0, 10));
    circlePedal();
    deltoidCata();
    hypotrochoid();
    pop();
 }

function deltoidCata(){
    //mapping colors to mouse
    colorR = map(mouseX, 0, width, 200, 255);
    colorB = map(mouseY, 0, height, 200, 255);
    
    //mapping factor of deltoid to mouse
    g = map(mouseX, 0, width, 0, 100);
    g = map(mouseY, 0, height, 25, 50);
    
    //stroke & fill
    strokeWeight(5);
    fill(colorR, 250, colorB);
    stroke(0);
    

    // creating deltoid catacaustic
    beginShape();
    for (var i = 0; i < 200; i ++) {
        
        var angle = map(i, 0, 200, 0, 2*(TWO_PI));
        //formula for deltoid catacaustic
        x= ((2 *(cos(angle))) + (cos(2*angle)))*g ;
        y= ((2 *(sin(angle))) - (sin(2*angle)))*g ;
        vertex(x,y);
    }
    endShape();
}

function circlePedal(){
    //mapping colors to mouse X & Y
    colorR = map(mouseX, 0, width, 80, 200);
    colorG = map(mouseX, 0, width, 0, 50);
    colorB = map(mouseY, 0, height, 70, 170);
    
    //mapping factor multiplied by to mouse X & Y
    t = map(mouseX, 0, width, 150, 250);
    t = map(mouseY, 0, height, 130, 200);
    
    //stroke & fill
    strokeWeight(2);
    fill(colorR, colorG, colorB);
    stroke(255);
    
    //creating circle pedal
    for (var i = 0; i < 500; i ++) {
        
        var angle = map(i, 0, 500, 0, 2*(TWO_PI));
        //formula for circle pedal
        var x1 = cos(angle);
        var y1 = sin(angle);
        var x2 = t *((cos(angle)) -( y1 * cos(angle) * sin(angle)) + (x1 * pow(sin(angle),2))); 
        var y2 = (.5* (y1 + (y1 * cos(2*angle))+ (2*sin(angle))- (x1 * sin(2*angle)))) * t;
        vertex(x2,y2);
    }
    endShape();
     
}

function hypotrochoid(){
    //mapping size of hypotrochoid to mouse
    a = map(mouseX, 0, width, 200, 350);
    b = map(mouseY, 0, height, 100, 200);
    h = map(mouseY, 0, height, 2, 105);
    
    //stroke & fill
    strokeWeight(2);
    noFill();
    stroke(255);

    // creating hypotrochoid
    beginShape();
    for (var i = 0; i < 500; i ++) {
        // hypotrochoid formula
        angle = map(i, 0, 500, 0, TWO_PI);
        var x = (a - b) * cos(angle) + h * cos((a - b) / b * i);
        var y = (a - b) * sin(angle) + h * sin((a - b) / b * i);
        vertex(x, y);
    }
    endShape();
}

//function gradient 
function createGradient(top, bottom) {
    for(var i = 0; i <= height; i++) {
      var mapColor = map(i, 0, height, 0, 1);
      var interA = lerpColor(top, bottom, mapColor);
      stroke(interA);
      line(0, i, width, i);
    }
}

I started the project with just creating the deltoid curve and the circle pedal curve, but realized that just them two together weren’t creating a very interesting composition even though the formulas to create them were pretty complex. Even with altering numbers, mapping values, and angle amounts, I still wasn’t getting anything particularly interesting or complex looking. So, I decided to add a more circular and dynamic curve of the hypotrochoid, which can be altered by various radii values and its repeating structure.

Joseph Zhang – Project 07 – E

For this project, I wanted to play with hypotrochoid forms and astroids in hopes of making something pretty dynamic. I had really brief understanding of roulettes from high school mathematics so a lot of my learning came from going through the Wolfram Alpha website and learning about each form. At the end, these were the two that I wanted to continue playing with.

Quiet honestly, I had no idea how it would come out at the end and much of the process just came from experimenting with mouse positions, mapping, and tweaking with equations. Below are some screenshots of its different forms.

sketch

// Joseph Zhang
// Section E
// haozhez@andrew.cmu.edu
// Project-07: Composition with Curves

var points = 2000;
var rotateCount = 0;

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

}

// calls each shape and continuously rotates the form
function draw() {
    background(20);
    push();
        translate(width / 2, height / 2);
        rotate(rotateCount);
        rotateCount++;
        drawAstroid();
        drawHypo();
    pop();
}

// draws the Astroid form (inside shape)
function drawAstroid() {
    // colors is dependent on mouse position
    colorR = map(mouseY, 0, width, 0, 255);
    colorG = map(mouseX , 0, width, 0, 255);
    colorB = map(mouseX , 0, width, 0, 255);
    stroke(colorR , colorG, colorB);
    noFill();
    strokeWeight(1);

    // for loop to draw astorid form
    beginShape();
    petal = int(map(mouseX, 0, width, 4, 10));
    size = int(map(mouseX, 0, width, 0, 100));
    for (var i = 0; i < points; i++){
        t = map(i, 0, points, 0, TWO_PI);
        x = (size / petal) * ((petal - 1) * cos(t) + cos((petal - 1) * t));
        y = (size / petal) * ((petal - 1) * sin(t) - sin((petal - 1) * t));
        vertex(x,y);
    }
    endShape();
}

// draws the hypotrochoid form (outside shape)
function drawHypo() {
    // colors is dependent on mouse position
    colorR = map(mouseX, 0, width, 0, 255);
    colorG = map(mouseY , 0, width, 0, 255);
    colorB = map(mouseY , 0, width, 0, 255);
    stroke(colorR , colorG, colorB);
    strokeWeight(1);
    
    //for loop to draw astroid form
    a =  map(mouseX, 0 , width, 200, 350);
    b =  map(mouseY, 0 , width, 100, 200); 
    h =  map(mouseY, 0 , width, 2, 105); 
    
    beginShape();
    for (var i = 0; i < 10000; i++){

        t = map(i, 0, 500, 0, TWO_PI);
        x = (a - b) * cos(t) + h * cos((a - b) * (t / b));
        y = (a - b) * sin(t) - h * sin((a - b) * (t / b));
        vertex(x, y);
    }
    endShape();
}

Form 1
Form 2
Form 3
Form 4

Monica Chang- Project-07-Curves

sketch

//Monica Chang
//mjchang@andrew.cmu.edu
//Section D
//Project-07-Curves

var nPoints = 100;
var radiusX;
var radiusY;
var separation = 125;

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

function draw() {
    background("darkcyan");
    fill(255, 255, 255, 64);
    
    radiusX = mouseX;
    radiusY = mouseY;

    drawCircles();
    drawEpitrochoidCurve();
    drawDeltoid();
}

//circle elements

function drawCircles() {
  
  // a sequence of little, circle elements
    push();
    translate(width / 2, height / 2);
    for (var i = 0; i < nPoints + 10; i++) {
        var theta = map(i, 0, nPoints, 0, TWO_PI);
        var px = radiusX / 2 * cos(theta);
        var py = radiusY / 2 * sin(theta);
      
        stroke("lightcyan");
        strokeWeight(1);
        circle(px - 5, py - 5, 8, 8);
    }
    pop();
  
}


function drawDeltoid() {
    //Deltoid:
    //http://mathworld.wolfram.com/Deltoid.html
    beginShape();
    nPoints = 40;
    for (var i = 0; i < nPoints; i++) {   
    	var angle = map(i, 0, 180, 0, 360);
        var radius = 70;
        var a = map(mouseX, 0, height, 5, 80)
        var b = map(mouseY, 0, height, 5, 90)
        
        //x-coordinate for deltoid
        var x = (a - b) * cos(angle) + radius * cos((a - b * angle));
        //y-coordinate for deltoid
        var y = (a - b) * sin(angle) - radius * sin((a - b * angle));
        rotate(radians(angle));
        noFill();
        strokeWeight(3);
        stroke("red");
        vertex(x, y);
      }
    endShape();
    

}

function drawEpitrochoidCurve() {
    // Epicycloid:
    // http://mathworld.wolfram.com/Epicycloid.html
    
    var x2;
    var y2;
    
    var a = 80.0;
    var b = a / 2.0;
    var h = constrain(mouseY / 8.0, 0, b);
    var ph = mouseX / 30.0;
    
    noFill();
    stroke("tan");
    strokeWeight(1);
    beginShape();
    translate(width / 2, height / 2);
    for (var i = 0; i < nPoints + 10; i++) {
        var t = map(i, 0, nPoints, 0, TWO_PI);
        
        x2 = (a + b) * cos(t) - h * cos(ph + t * (a + b) / b);
        y2 = (a + b) * sin(t) - h * sin(ph + t * (a + b) / b);
      
        //switching x and y-coordinates to create a band of waves/
        vertex(x2, y2);
        vertex(y2, x2);
    }
    endShape(CLOSE);
    
}

Bottom Left
Bottom Right
Top Left
Top Right

This project definitely had me studying the formulas 75% of the time for me to really start putting anything together. However, once I got the gist of the formulas, it was really entertaining for me. I began with studying the deltoid curve and I realized this particular curve created so many different shapes. Thus, I wanted to provide a more constant curve which became the sequence of circles which are relatively more static to create a sense of balance.

Kimberlyn Cho- Project 07- Curves

ycho2-07

/* Kimberlyn Cho
Section C
ycho2@andrew.cmu.edu
Project-07 */

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

function draw() {
	push();
	background(0);
	strokeWeight(2);
	noFill();
	translate(width / 2, height / 2);
	stroke(188, 19, 254);
	drawHypotrochoidCurve();
	stroke(250, 237, 39)
	drawEpitrochoidCurve();
	pop();
};

//Hypotrochoid Curve
function drawHypotrochoidCurve() {
	//http://mathworld.wolfram.com/Hypotrochoid.html

	//equations
	var x;
	var y;

	//parameters to control curve
	var a = map(mouseX, 0, width, 0, 200)
	var b = a / 20
	//curve radius
	var h = map(mouseY, 0, height, 0, 200)

	//drawing curve
	push();
	beginShape();
	for (var i = 0; i < 100; i ++) {
		var t = map(i, 0, 100, 0, TWO_PI)
		x = (a - b) * cos(t) + h * cos(((a - b) / b) * t)
		y = (a - b) * sin(t) - h * sin(((a - b) / b) * t)
		vertex(x, y)
	};
	endShape();
	pop();
} 

//Epitrochoid Curve
function drawEpitrochoidCurve() {
	//http://mathworld.wolfram.com/Epitrochoid.html

	//equations
	var x;
	var y;

	//parameters to control curve
	var a = map(mouseX, 0, width, 0, 250)
	var b = a / 20
	//curve radius
	var h = map(mouseY, 0, height, 0, 250)

	//drawing curve
	push();
	beginShape();
	for (var i = 0; i < 100; i ++) {
		var t = map(i, 0, 100, 0, TWO_PI)
		x = (a + b) * cos(t) - h * cos(((a + b) / b) * t)
		y = (a + b) * sin(t) - h * sin(((a + b) / b) * t)
		vertex(x, y)
	};
	endShape();
	pop();
} 

I found the flexibility of this project to be fun in the multitude of possible outcomes it allowed for even with the same kind of curves. The initial exploration of the various equations and curves was interesting– especially in discovering cool, interesting shapes or curves with just math equations. Although the complex equations were intimidating in my first approach to the project, it was pretty amusing to see how the curves reacted to changes in the different parameters. I chose to layer two different types of curves to create an illusion of depth and overlap. Overall, I enjoyed this project and think it was a great introduction to a mathematical approach to design through p5js.

state 1
state 2

Alec Albright – Project 07 – Curves

sketch

// Alec Albright
// aalbrigh@andrew.cmu.edu
// Section B
// Project 07

var nPoints = 100; // number of points used to draw curves

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

function draw(){
    background("lightpink");

    // center the shapes
    push();
    translate(width / 2, height / 2);

    // draw all the shapes
    drawHippopede();
    drawEpicycloid();
    drawHypotrochoid();

    pop();
}

// draws Hippopede
function drawHippopede() {
    var x; // x coordinate of vertex
    var y; // y coordinate of vertex
    var r; // polar coordinate
    var a = mouseX / 2 // main parameter of the curve
    var b = map(a, 0, 480, 100, 240); // circle radius
    var rotation = map(mouseY, 0, 480, 0, TWO_PI); // amount of rotation

    // thickness of line proportional to the circle radius
    strokeWeight(b / 5);
    stroke("white");
    noFill();

    // rotate shape
    push();
    rotate(rotation);

    // start drawing the shape, one point at a time
    beginShape();
    for(var i = 0; i < nPoints; i++){
        var t = map(i, 0, nPoints, 0, TWO_PI);
        
        // find r (polar equation)
        r = sqrt(4 * b * (a - b * sinSq(t)));

        // convert to x and y coordinates
        x = r * cos(t);
        y = r * sin(t);

        // draw a point at x, y
        vertex(x, y);
    }
    endShape();
    pop();
}

// draws hypotrochoid
function drawHypotrochoid() {
    var x; // x coordinate of vertex
    var y; // y coordinate of vertex
    var a = map(mouseX, 0, 480, 50, 150); // radius of the interior circle
    var b = 3; // radius of the petals
    var h = mouseX / 10; // distance from center of interior circle
    var red = map((mouseX + mouseY) / 2, 0, 480, 0, 255); // how much red
    var blue = map(mouseY, 0, 480, 0, 255); // how much blue
    var alpha = map(mouseX, 0, 480, 50, 255); // how opaque
    var rotation = map(mouseY, 100, 300, 0, TWO_PI); // amount of rotation

    strokeWeight(2)
    stroke("white");

    // control color and opacity with mouse location
    fill(red, 0, blue, alpha);

    // control rotation with mouseY
    push();
    rotate(rotation);

    // create the shape itself
    beginShape();
    for(var i = 0; i < nPoints; i++) {
        var t = map(i, 0, nPoints, 0, TWO_PI);

        // use parametric euqations for hypotrochoid to find x and y
        x = (a - b) * cos(t) + h * cos((a - b) / b * t);
        y = (a - b) * sin(t) - h * sin((a - b) / b * t);

        // draw a point at x, y
        vertex(x, y)
    }
    endShape(CLOSE);
    pop();
}

// draws an epicycloid
function drawEpicycloid() {
    var x; // x coordinate of vertex
    var y; // y coordinate of vertex
    var a = map(mouseX, 0, 480, 50, 200); // radius of interior circle
    var b = map(mouseY, 0, 480, 10, 50); // radius of petals
    var blue = map((mouseX + mouseY) / 2, 0, 480, 0, 255); // how much blue
    var red = map(mouseY, 0, 480, 0, 255); // how much red
    var rotation = map(mouseY, 100, 300, 0, TWO_PI); // how muhc rotation

    // control color with mouse location
    strokeWeight(10)
    stroke(red, 0, blue);

    // control rotation with mouse location
    push();
    rotate(rotation);

    // start drawing shape
    beginShape();
    for(var i = 0; i < nPoints; i++) {
        var t = map(i, 0, nPoints, 0, TWO_PI);

        // find coordinates using epicycloid parametric equations
        x = (a + b) * cos(t) - b * cos((a + b) / b * t);
        y = (a + b) * sin(t) - b * sin((a + b) / b * t);

        // draw a point at x, y
        vertex(x, y);
    }
    endShape();
    pop();
}

// defines sin^2 using trigonometric identities
function sinSq(x) {
    return((1 - cos(2 * x)) / 2);
}

In order to put together this project, I started with a simple curve, the hippopede, and began to implement increasingly more complex ones. Once I was able to draw the three curves (hippopede, hypotrochoid, and epicycloid), I started mapping various features of the curves to things like color, transparency, stroke weight, and rotation until I was satisfied with the results. Particularly, the color mapping was interesting to me because I utilized the average of the mouseX and mouseY coordinates in order to determine some aspects of color like the amount of red in the hypotrochoid and the amount of blue in the epicycloid. This allowed me to have more freedom to speculate interesting relationships that could be created using the coordinate system.

mouseX = 400, mouseY = 50
mouseX = 240, mouseY = 400
mouseX = 50, mouseY = 200
mouseX = 480, mouseY = 240

Alice Cai Project 7

sketch

//alcai@andrew.cmu.edu
//alice cai
//section E
//Project Week 7

//spinning speed
var speed = 0;

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

function draw() {
    frameRate(30);
    background('black');

    push();
    //draw at middle of canvas
    translate(width/2, height/2);
    //rotate speed, rotates on its own but also adjusted by mouse X
    rotate(speed + mouseX, 0, 200, 0, TWO_PI); 
    speed = speed + 1;
    //call droid draw functions
    epicycloid();
    astroid();
    epitrochoid();
    pop();

}


function epicycloid(){ 
    noFill();
    strokeWeight(2);
    stroke(mouseX, 100, 130,150);
    

    beginShape();
    //defining variables, size is corntroled by mouseX/mousY
    a = map(mouseX, 0, width, 50,300);
    b = map(mouseY, 0, width, 50,300);
    //forloop that repeats shape
    for (var t = 0; t < 40; t ++) {
    var x = (a / (a + 2 * b)) * cos(t) - b * cos(((a + b) / b) * t);
    var y = (a / (a + 2 * b)) * sin(t) - b * sin(((a + b) / b) * t);
    vertex(x ,y);
    endShape();

}
}

function epitrochoid (){
    noFill();
    strokeWeight(5);
    stroke(200,10,100, 5);

    beginShape();

    //forloop that repeats shape
    for (var i = 0; i < 100; i ++) { 

    //defining variables, size is corntroled by mouseX/mousY
    a = map(mouseX, 0, width, 50,300);
    b = map(mouseX, 0, width, 50,300);
    h = map(mouseX, 0, width, 50,200);  

    x = (a + b) * cos(i/2) - (h * cos((a + b / b) * i));
    y= (a + b) * sin(i/2) - (h * sin((a + b / b) * i));
    vertex(x, y);
    endShape();
    }
}



function astroid(){ 
    noFill();
    strokeWeight(5);
    stroke(130, 100, 150,150);

    

    beginShape();

    //forloop that repeats shape
    for (var t = 0; t < 20; t ++) {
        
    //defining variables, size is corntroled by mouseX/mousY
    z = map(height - mouseY, 0, width, 50,200);
    var x = z * cos(t)^ 3 ;
    var y = z * sin (t)^ 3 ;
    vertex(x ,y);
    endShape();

    }

}

This project seemed really daunting because all the shapes looked complex and there was a lot going on on the screen, especially those with mouse interaction. Turns out, it’s not as complex as it seems. Although the equations may seem complex, they are also given to us. After that, it’s just about defining the variables in the equation and calling a for loop to draw a pattern with the shape! I used a map function to control the size of the shape with mouseX and mouseY. I also changed the opacity of the line strokes for a more transparent and three-dimensional looks.

TWO SHAPES
THREE SHAPES with varying opacity
A better capture of the visual effect of lower opacity