Public
Edited
Dec 6, 2023
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
julia_morph = {
let t1, t2, inv1, inv2;
if (t < 1 / 2) {
t1 = 2 * t;
t2 = 0;
inv1 = (z) => math.pow(z.sub(math.multiply(t1, c)), math.divide(2 - t2, 2));
inv2 = (z) =>
math.pow(z.sub(math.multiply(t1, c)), math.divide(2 - t2, 2)).mul(-1);
} else {
t1 = 1;
t2 = 2 * t - 1;
inv1 = (z) => math.pow(z.sub(math.multiply(t1, c)), math.divide(2 - t2, 2));
inv2 = (z) =>
math.pow(z.sub(math.multiply(t1, c)), math.divide(2 - t2, 2)).mul(-1);
}

return Plot.plot({
marks: [
Plot.dot(JPoints, { x: "re", y: "im", r: 1, fill: "lightgray" }),
Plot.dot(JPoints.map(inv1), { x: "re", y: "im", r: 1, fill: "blue" }),
Plot.axisX({ y: 0 }),
Plot.axisY({ x: 0, ticks: 5 }),
Plot.ruleX([0]),
Plot.ruleY([0]),
t == 1
? Plot.dot(JPoints.map(inv2), { x: "re", y: "im", r: 1, fill: "red" })
: null,
t == 1
? Plot.text(
[
{ text: "+", color: "blue", x: 1.4, y: 1.3 },
{ text: "-", color: "red", x: -1.4, y: 1.3 }
],
{
text: "text",
fill: "color",
x: "x",
y: "y",
fontSize: 30
}
)
: null
],
x: { domain: [-2, 2], label: "re" },
y: { domain: [-1.6, 1.6], label: "im" },
width: 0.5 * width,
height: (0.5 * width) / 1.25
});
}
Insert cell
JPoints = {
let w = Math.round(width / 2);
let s = 2;
let J = new QuadraticJuliaSet(c);
let M = J.generate_inverse_iterate_matrix({
width: w,
height: w,
extent: [
[-s, s],
[-s, s]
]
});

let zs = [];
for (let i = 0; i <= w; i++) {
for (let j = 0; j <= w; j++) {
if (M[j][i] > 0) {
let [x, y] = [-s + (2 * s * j) / w, s - (2 * s * i) / w];
zs.push(math.complex(x, y));
}
}
}

return zs;
}
Insert cell
viewof c = {
let xmin = -2;
let xmax = 0.6;
let ymin = -1.3;
let ymax = 1.3;
let s = d3.min([450, width / 2]);
let canvas = d3.create("canvas").attr("width", s).attr("height", s);
draw_mandelbrot_set(canvas.node(), xmin, xmax, ymin, ymax);
let x_scale = d3.scaleLinear().domain([0, s]).range([xmin, xmax]);
let y_scale = d3.scaleLinear().domain([s, 0]).range([ymin, ymax]);
canvas.on("click", function (evt) {
let [X, Y] = d3.pointer(evt);
let x = x_scale(X);
let y = y_scale(Y);
canvas.node().value = math.complex(x, y);
canvas.node().dispatchEvent(new CustomEvent("input"));
});
canvas.node().value = math.complex(-1);
return canvas.node();
}
Insert cell
import { draw_mandelbrot_set } from "@mcmcclur/julia-sets-and-the-mandelbrot-set"
Insert cell
import { QuadraticJuliaSet } from "3897c7fe05d9fd50"
Insert cell
math = require("mathjs")
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more