Public
Edited
Nov 28, 2022
2 forks
2 stars
Insert cell
Insert cell
Insert cell
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([1 / p ** 2, 1 / p ** 2])
.compose(scale(1 / p ** 2))
.compose(rotate(pi / 2)),
label: "SR3"
},
{
// Upper right rectangle in square
source: "S",
target: "R",
f: shift([1 / p ** 2, 1 / p]).compose(scale(1 / p ** 2)),
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
smaller_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([1 / p ** 2, 1 / p ** 2])
.compose(scale(1 / p ** 2))
.compose(rotate(pi / 2)),
label: "SR3"
},
{
// Upper right rectangle in square
source: "S",
target: "R",
f: shift([1 / p ** 2, 1 / p]).compose(scale(1 / p ** 2)),
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
digraphIFS = new DigraphIFS(smaller_digraph_input)
Insert cell
Insert cell
digraphIFS.show_digraph()
Insert cell
Insert cell
pics = digraphIFS.render_stochastic({ n: 100000, colors: true })
Insert cell
Insert cell
pics[2]
Insert cell
Insert cell
Insert cell
## Ancillary code
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
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

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