Public
Edited
Apr 20, 2023
15 stars
A Julia set on the Riemann sphereThe Z-CurveBarnsley's fernA stochastic digraph IFS algorithmSelf-affine tilesThe TwindragonThe Eisenstein fractionsA self-affine tile with holesSelf-affine tiles via polygon mergeGolden rectangle fractalsBifurcation diagram with critical curvesThe tame twindragonIllustrations for the proof of Green's theoremNon-orientability of a Mobius stripExamples of parametric surfaces
Penrose tiling
The extended unit circlePenrose three coloringNewtons's method on the Riemann sphereConic sectionsDivisor graphsThe dance of Earth and VenusIterating multiples of the sine functionBorderline fractalsSelf-similar intersectionsBox-counting dimension examplesMandelbrot by dimensionInverse iteration for quadratic Julia setsInteger Apollonian PackingsIllustrations of two-dimensonal heat flowThe logistic bifurcation locusThe eleven unfoldings of the cubeA unimodal function with fractal level curvesGreen's theorem and polygonal areaThe geometry and numerics of first order ODEsThe xxx^xxx-spindleAnimated beatsRauzy FractalsHilbert's coordinate functionsPluckNot PiDrum strikeThe Koch snowflakeFractalized squareA Taylor series about π/4\pi/4π/4PlotX3D HyperboloidA PlotX3D animationModular arithmetic in 5th grade artSimple S-I-R ModelThe Poisson KernelPoly-gasketsClassification of 2D linear systems via trace and determinantJulia sets and the Mandelbrot setWater wavesFourier SeriesDisks for a solid of revolutionOrbit detection for the Mandelbrot setTracing a path on a spherePlot for mathematiciansFunctions of two variablesPartial derivativesDijkstra's algorithm on an RGGGradient ascentUnfolding polyhedraTangent plane to a level surfaceA strange discontinuityExamples of level surfacesMcMullen carpetsHills and valleysThe definition of ⇒Double and iterated integralsMST in an RGGTrees are bipartiteFractal typesettingd3.hierarchy and d3.treeK23 is PlanarPolar CoordinatesParametric region generatorParametric Plot 2DContour plotsGreedy graph coloringGraph6A few hundred interesting graphsThe Kings ProblemFirst order, autonomous systems of ODEsRunge-Kutta for systems of ODEs
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
function make_penrose_tiling() {
let svg_width = 800;
let svg_height = (2 * svg_width) / phi ** 2;
let xmin = 0;
let xmax = phi;
let ymin = -1 / phi;
let ymax = 1 / phi;

let svg = d3
.create("svg")
.style("max-width", `${svg_width}px`)
.attr("viewBox", [0, 0, svg_width, svg_height]);
// .attr("width", svg_width)
// .attr("height", svg_height);

let x_scale = d3.scaleLinear().domain([xmin, xmax]).range([0, svg_width]);
let y_scale = d3.scaleLinear().domain([ymin, ymax]).range([svg_height, 0]);
let pts_to_path = d3
.line()
.x(function (d) {
return x_scale(d[0]);
})
.y(function (d) {
return y_scale(d[1]);
});

svg
.selectAll("path")
.data(triangles)
.join("path")
// Piece together the triangles to form either Rhombs or Kites and Darts
// depending whether depth is odd or even
.attr("d", function (d) {
if (depth % 2 == 0) {
return pts_to_path([d.vertices[1], d.vertices[2], d.vertices[0]]);
} else {
if (d.type == "a") {
return pts_to_path([d.vertices[2], d.vertices[0], d.vertices[1]]);
} else {
return pts_to_path([d.vertices[0], d.vertices[1], d.vertices[2]]);
}
}
})
.attr("stroke", "black")
.attr("stroke-width", 1)
.attr("fill", function (d) {
if (d.type == "o") {
return "#B0B7BC";
} else {
return "#CE0F3D";
}
});

if (show_diag) {
svg
.selectAll("path.diag")
.data(triangles)
.join("path")
.attr("d", function (d) {
if (depth % 2 == 0) {
return pts_to_path([d.vertices[1], d.vertices[0]]);
} else {
if (d.type == "a") {
return pts_to_path([d.vertices[2], d.vertices[1]]);
} else {
return pts_to_path([d.vertices[0], d.vertices[2]]);
}
}
})
.attr("stroke", "black")
.attr("stroke-width", 0.6)
.attr("stroke-dasharray", "5,5")
.attr("fill", null);
} else {
svg
.selectAll("path.diag")
.data(triangles)
.join("path")
.attr("d", function (d) {
if (depth % 2 == 0) {
return pts_to_path([d.vertices[1], d.vertices[0]]);
} else {
if (d.type == "a") {
return pts_to_path([d.vertices[2], d.vertices[1]]);
} else {
return pts_to_path([d.vertices[0], d.vertices[2]]);
}
}
})
.attr("stroke", function (d) {
if (d.type == "o") {
return "#B0B7BC";
} else {
return "#CE0F3D";
}
})
.attr("stroke-width", 1)
.attr("fill", null);
}
return svg.node();
}
Insert cell
triangles = {
let triangles = [S];
for (let i = 0; i < depth; i++) {
triangles = triangles.map(dissect(i)).reduce(function(a, c) {
return a.concat(c);
}, []);
}
triangles = triangles.concat(
triangles.map(function(o) {
let newo = Object.assign({}, o);
newo.vertices = o.vertices.map(function(xy) {
let x = xy[0];
let y = -xy[1];
return [x, y];
});
return newo;
})
);
return triangles;
}
Insert cell
// When i is even, we dissect the acute triangles but
// when i is odd, we dissect the obtuse triangles.
function dissect(i) {
let i_dissect = function(T) {
let T1, T2;
let [p, q, r] = T.vertices;
if (T.type == 'a') {
if (i % 2 == 0) {
let new_point = [
(phi * q[0] + p[0]) * (2 - phi),
(phi * q[1] + p[1]) * (2 - phi)
];
T1 = {
vertices: [r, new_point, q],
type: 'a'
};
T2 = {
vertices: [r, new_point, p],
type: 'o'
};
return [T1, T2];
} else {
return [T];
}
} else if (T.type == 'o') {
if (i % 2 == 1) {
let new_point = [
(phi * r[0] + p[0]) * (2 - phi),
(phi * r[1] + p[1]) * (2 - phi)
];
T1 = {
vertices: [r, new_point, q],
type: 'o'
};
T2 = {
vertices: [p, q, new_point],
type: 'a'
};
return [T1, T2];
} else {
return [T];
}
}
};

return i_dissect;
}
Insert cell
// Start with a single obtuse triangle
S = ({
vertices: [[phi, 0], [phi / 2, Math.sin(Math.PI / 5)], [0, 0]],
type: 'o'
})
Insert cell
phi = (Math.sqrt(5) + 1) / 2
Insert cell
import { slider, checkbox } from "@jashkenas/inputs"
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