Public
Edited
Mar 14
2 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
function color(info, bail) {
let v = 255 * (1 - info.cnt / (bail + 1)) ** 2;
let lim = info.lim;
if (lim == 0) {
return [0, 0, v];
} else if (lim == 1) {
return [v, 0, 0];
} else if (lim == 2) {
return [v, v, 0];
} else {
return [0, 0, 0];
}
}
Insert cell
function orbitInfo([x0, y0], bail) {
let cnt = 0;
let x = x0;
let y = y0;
let lim = classify([x, y]);
while (lim == 3 && cnt < bail) {
[x, y] = N([x, y]);
lim = classify([x, y]);
cnt = cnt + 1;
}
return { lim: lim, cnt: cnt };
}
Insert cell
function classify([x, y]) {
if ((x - 1) ** 2 + y ** 2 < 0.01) {
return 0;
} else if ((x + 0.5) ** 2 + (y - 0.8660254) ** 2 < 0.01) {
return 1;
} else if ((x + 0.5) ** 2 + (y + 0.8660254) ** 2 < 0.01) {
return 2;
} else {
return 3;
}
}
Insert cell
// The complex Newton's method iteration function expressed
// in terms of the real and imaginary parts of z=x+iy.
function N([x, y]) {
let denominator = 3 * (x ** 2 + y ** 2) ** 2;
let numerator_re =
x ** 2 + 2 * x ** 5 - y ** 2 + 4 * x ** 3 * y ** 2 + 2 * x * y ** 4;
let numerator_im =
-2 * x * y + 2 * x ** 4 * y + 4 * x ** 2 * y ** 3 + 2 * y ** 5;
return [numerator_re / denominator, numerator_im / denominator];
}
Insert cell
rotate = d3
.select(riemann_sphere)
.select('#rotation')
.attr('rotation', `0 0 1 ${rotation}`)
Insert cell
rotation_values = d3.range(0, 2 * Math.PI, Math.PI / 400)
Insert cell
import { Scrubber } from "@mbostock/scrubber"
Insert cell
d3 = require('d3@6')
Insert cell
x3dom = require('x3dom').catch(() => window['x3dom'])
Insert cell
html`
<style>
canvas {
outline: none
}
output {
display: none
}
</style>
`
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