fractalkitty looking for math? fractalkitty.com

Mathober 2026 ยท day 1, Perimeter of an Ellipse

Perimeter of an Ellipse

#random#trig#interactive#animation#accumulates#math#geometry#symmetry#mathober

whatTheLegsMustWalktheLittleBitOfRandomnessneedsALittleBitOfRandomnesstheFinalApproximationeccentricityepsilon

let whatTheLegsMustWalk = 0
let theLittleBitOfRandomness
let needsALittleBitOfRandomness
function setup() {
	theSizeThatFits = min(windowWidth, windowHeight)*0.9
	theCanvasThatIsFilled=createCanvas(theSizeThatFits, theSizeThatFits);
	background(20,70,80);
	noFill();
	strokeWeight(0.5);
	theLittleBitOfRandomness = int(random(10,50))*20;
	needsALittleBitOfRandomness=int(random(10,50))*20;
	describe("ellipses are drawn in a way that spins around the center of a teal canvas with color changes based on both time and the perimeter of the ellipse. They have think lines to give a sketchy feel and create rotationally symmetric visuals with some color patterning and moire.")
}

function draw() {
	for(let i = 0;i<10;i++){
	const a = abs(sin(frameCount/1000))+0.000001
	const b = abs(cos(frameCount/theLittleBitOfRandomness)*sin(frameCount/needsALittleBitOfRandomness+random(0,PI/4)))+0.000001
	theFinalApproximation(a,b);
	theColorNotes = map(whatTheLegsMustWalk,0.00001,TWO_PI,20,255 - 50*cos(frameCount/300));
	stroke(30*abs(sin(frameCount/(550)))+theColorNotes*0.5,10*abs(sin(frameCount/(300)))+theColorNotes*0.9,theColorNotes,5)
		push()
		translate(theSizeThatFits/2,theSizeThatFits/2)
		rotate(frameCount/theLittleBitOfRandomness)
	ellipse(0,0,a*theSizeThatFits,b*theSizeThatFits);
		pop()
	}
}
function theFinalApproximation(a,b){
	const h = ((a-b)*(a-b))/((a+b)*(a+b));
	const eccentricity = sqrt(abs(1-(b*b)/(a*a)));
	const epsilon = (3*a*pow(eccentricity,20))/pow(2,36);
	whatTheLegsMustWalk = abs(PI*((a+b)*(1+(3*h)/(10+sqrt(4-3*h)))+epsilon));
}

function keyPressed(){
	if(keyCode===83){
		save(theCanvasThatIsFilled,"Perimeter of Ellipse","png")
	}
}