loosely based on Advent of Code 2024 - 02
fun fact: this fusion image consists entirely of toric sections
Log in to post a comment.
Canvas.setpenopacity(-1.0); const t = new Turtle(); function draw_point(phi, r) { let x = r * Math.cos(phi); let y = r * Math.sin(phi); let dir = 360 * Math.random(); for (let i = 0; i < 2; i++) { t.jump(x, y); t.seth(dir + i * 180); t.forward(1.2); } } function draw_cassini_oval(a, b) { const N = 300; let e = b / a; for (let i = 0; i < N; i++) { let phi = 2 * Math.PI * Math.random(); let phi2 = 2 * phi; let cosphi2 = Math.cos(phi2), sinphi2 = Math.sin(phi2); let D2 = e**4 - sinphi2**2; if (D2 >= 0) { let D = Math.sqrt(D2); let r2 = a**2 * (cosphi2 - D); if (r2 > 0) { let r = Math.sqrt(r2); draw_point(phi, r); draw_point(phi, -r); } let R2 = a**2 * (cosphi2 + D); if (R2 > 0) { let R = Math.sqrt(R2); draw_point(phi, R); draw_point(phi, -R); } } } } const A = 66; for (let i = 0; i < 200; i++) { draw_cassini_oval(A, 2.5 * A * (Math.random() ** 2)); }