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

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more