Published
Edited
Nov 28, 2020
1 fork
5 stars
Insert cell
Insert cell
imshow(data, 0.5, colorScales[color])
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
complexFunctions = ({
"Gamma Function": math.gamma,
"csc": math.csc,
"sin": math.sin,
"log": math.log,
"exp": math.exp,
"sqrt": math.sqrt,
"1/z": d => math.divide(1, d),
"Identity": d => d,
"asin": math.asin,
})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
function checkerBoard(x, y) {
return Math.abs(Math.abs(Math.floor(x) % 2) - Math.abs(Math.floor(y) % 2));
}
Insert cell
Insert cell
Insert cell
Insert cell
function latticeProximity(x, y) {
// alpha: prevent divergence of log - the smaller the sharper
const dx = - Math.log(alpha + Math.abs(x - Math.round(x)));
const dy = - Math.log(alpha + Math.abs(y - Math.round(y)));
// Normalize
const minVal = - 2 * Math.log(alpha + 0.5);
const maxVal = - 2 * Math.log(alpha);
// range of return value: [0, 1]
return (dx + dy - minVal) / (maxVal - minVal);
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
function convert(x, y) {
const c = complexFunctions[selectedFunction](math.complex(x, y));
return [c.re, c.im];
}
Insert cell
Insert cell
data = {
const resolution = 800; // # of pixels
const range = 3; // drawing range

const invertedLattice = d3.cross(
d3.range(-range, range, 2*range/resolution).reverse(),
d3.range(-range, range, 2*range/resolution)
).map(coord => method(...convert(...coord.reverse())));

return math.reshape(invertedLattice, [resolution, resolution]);
}
Insert cell
Insert cell
Insert cell
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