For this project I explored the conchoid of de Sluze curve. I thought this curve was interesting because it reflects different curves across a vertical access depending on if the equation is multiplied by a positive or negative “a”. This reminded me of a galaxy being pinched and forming from space matter so I added a rocket and stars into the background. It also looks like a planet is forming from space matter. The colors change based on the mouse position, the sizes of the curves also change based on mouse position, and when you keep your mouse pressed you can make the right half of the curve (changed “a” value).
//Graana Khan
//Section B
// 07 - Project - Curve Composition
var p = 500; //number of points
var x;
var y;
var a;
function setup() {
createCanvas(480, 480);
background(0);
}
function draw() {
//drawing the conchoid curve
push();
translate(width/2, height/2);
scale(25);
conchoid();
pop();
//adding the stars in the background
stars(50, 50);
stars(230, 350);
stars(400, 400);
stars(380, 100);
stars(200, 150);
stars(460, 240);
stars(70, 430);
stars(100, 270);
stars(300, 300);
//rocket in corner
x = 70;
y = 400;
rocket();
}
//function for the conchoid of de Sluze
function conchoid(){
beginShape();
stroke(mouseX-200, mouseY-100, 200); //color changes on mouse position
strokeWeight(0.01);
noFill();
//creating loop for the curves
for(var i =0; i < p; i++){
var t = map(i, 0, p, 0, 2*PI);
if(mouseIsPressed){ //a values switch from positive to negative if mouse is pressed
a = mouseX/100;
} else {
a = -1*(mouseX/50);
}
//equations are from https://mathworld.wolfram.com/ConchoidofdeSluze.html
x = ((1/cos(t)) + (a*cos(t)))* cos(t);
y = ((1/cos(t)) + (a*cos(t)))* sin(t);
vertex(x,y);
}
endShape();
}
//function for making the stars
function stars(x,y){
stroke(255);
line(x, y-5, x, y+5);
line(x-5, y, x+5, y);
}
//rocket in the corner
function rocket(){
push();
translate(x,y);
rotate(radians(45));
noStroke();
fill(255);
rect(0, 0, 14, 28, 2);
triangle(0, 0, 7, -13, 14, 0);
triangle(0, 8, 0, 16, -4, 16);
triangle(14, 8, 14, 16, 18, 16);
stroke(255, 0, 0);
line(2, 30, 2, 40);
line(11, 30, 11, 42);
stroke(244, 128, 11);
line(5, 30, 5, 45);
stroke(244, 238, 11);
line(8, 30, 8, 37);
noStroke();
fill(0);
circle(7, 10, 8);
pop();
}