xxxxxxxxxx
let N = 0;
function setup() {
createCanvas(500, 500);
}
function draw() {
background(225);
translate(width / 2, height / 2);
scale(20);
drawParametric();
composition();
let t = millis() / 1000;
N = (1 / 2) * (2 * cos(t + PI) + 2);
}
function trig(x, y) {
let u = (x - PI * y) / exp(1);
let v = (y - PI * x) / exp(1);
return sin(x) * sin(y) + sin(u) * cos(v);
}
function drawParametric() {
noFill();
strokeWeight(0.05);
beginShape();
for (let t = 0; t < 1; t += 0.0001) {
let angle = 150 * PI * t;
let x = 10 * t * cos(angle);
let y = 10 * t * sin(angle);
vertex(x, y);
}
endShape();
}
function composition() {
noFill();
strokeWeight(0.05);
beginShape();
for (let t = 0; t < 1; t += 0.00005) {
let angle = 150 * PI * t;
let xBase = 10 * t * cos(angle);
let yBase = 10 * t * sin(angle);
let x = funcX(xBase, yBase);
let y = funcY(xBase, yBase);
vertex(x, y);
}
endShape();
}
function funcX(x, y) {
let magnitude = sqrt(x * x + y * y);
let value = (N * trig(x, y) + magnitude) / magnitude;
return value * x;
}
function funcY(x, y) {
let magnitude = sqrt(x * x + y * y);
let value = (N * trig(x, y) + magnitude) / magnitude;
return value * y;
}