Published
Edited
Nov 22, 2021
Importers
3 stars
Also listed in…
Digraph Fractals
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
p = (1 + Math.sqrt(5)) / 2
Insert cell
full_digraph_input = [
{
// Rectangle in rectangle
source: "R",
target: "R",
f: shift([p, 0])
.compose(rotate(pi / 2))
.compose(scale(1 / p)),
label: "RR"
},
{
// Square in rectangle - don't delete!!
source: "R",
target: "S",
f: scale(1),
label: "RS"
},
{
// Lower left rectangle in square
source: "S",
target: "R",
f: scale(1 / p ** 2),
label: "SR1"
},
{
// Lower right rectangle in square
source: "S",
target: "R",
f: shift([1 / p + 1 / p ** 2, 0])
.compose(scale(1 / p ** 2))
.compose(rotate(pi / 2)),
label: "SR2"
},
{
// Upper left rectangle in square
source: "S",
target: "R",
f: shift([0, 1])
.compose(scale(1 / p ** 2))
.compose(rotate((3 * pi) / 2)),
label: "SR3"
},
{
// Upper right rectangle in square
source: "S",
target: "R",
f: shift([1, 1])
.compose(scale(1 / p ** 2))
.compose(rotate(pi)),
label: "SR4"
},
{
// Square in square
source: "S",
target: "S",
f: shift([1 / p ** 2, 1 / p ** 2]).compose(scale(1 / p ** 3)),
label: "SS"
}
]
Insert cell
Insert cell
full_digraphIFS = new DigraphIFS(full_digraph_input)
Insert cell
Insert cell
// Good initiators for the deterministic method
init = [
[
[0, 0],
[p, 0],
[p, 1],
[0, 1],
[0, 0]
],
[
[0, 0],
[1, 0],
[1, 1],
[0, 1],
[0, 0]
]
]
Insert cell
Insert cell
full_digraphIFS.render_deterministic("S", {
initiators: init,
max_depth: 3,
color_depth: 3,
colors: ["lightgray", "#D11E00"],
stroke: true
})
Insert cell
Insert cell
{
let clone = full_digraph_input.map((o) => Object.assign({}, o));
clone.splice(5, 1);
return new DigraphIFS(clone).render_deterministic("R", {
max_depth: 7,
initiators: init,
colors: false
});
}
Insert cell
Insert cell
{
let clone = full_digraph_input.map((o) => Object.assign({}, o));
clone.splice(5, 1);
return new DigraphIFS(clone).render_deterministic("R", {
max_depth: Infinity,
tolerance: 0.005,
initiators: init,
colors: false
});
}
Insert cell
Insert cell
import {
scale,
shift,
rotate,
reflect,
pi,
DigraphIFS
} from "@mcmcclur/digraphifs-class"
Insert cell
MathJax = require("https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js").catch(
() => window["MathJax"]
)
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