fractalkitty looking for math? fractalkitty.com

codepen challenges

plateauRipples

#trig#animation#math#wave#codepen-challenge

num1plateau

let a = 400,
	num1 = 4;
let m = 2,
	n2 = 4;
let t1;
function setup() {
	createCanvas(windowWidth, windowHeight);
	angleMode(DEGREES);
	stroke(255);
	noFill();
	strokeWeight(0.03);
}

function draw() {
	translate(width / 2, height / 2);
	background(250, 250, 250, 5);
	t1 = 360 * sin(frameCount / 100);
	stroke(
		5 * abs(sin(t1 * 3)) + 175,
		10 * abs(sin(t1 * 3)) + 175,
		50 * abs(sin(t1 * 3)) + 175
	);
	for (let i = num1; i > 0; i--) {
		plateau(i);
		push();
		scale(-1, 1);
		plateau(i);
		pop();
	}

	m = 10 * sin(t1 / 5) + 1;
	n = 10 * cos(t1 / 10) + 2;
}

function plateau(n) {
	beginShape();
	for (t = -360; t <= 360; t++) {
		x = (a * sin((m + n2) * t + n + t1)) / sin((m - n2) * t + n + t1);
		y = (2 * a * sin(m * t + n) * sin(n2 * t + n)) / (sin(m - n2) * t + n);
		vertex(x, y);
	}
	endShape(CLOSE);
}