Published
Edited
Dec 1, 2021
2 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// Note that the matrix AInv, the digit set D,
// and the set of shifts F are defined below.

digraphIFS = {
let edges = [];
let eps = 0.00000001;
for (let i = 0; i < F.length; i++) {
for (let j = 0; j < F.length; j++) {
D.forEach(function (d) {
D.forEach(function (dp) {
let alpha = F[i];
let beta = F[j];
let Aalpha = math.multiply(A, alpha);
let x = Aalpha[0] + dp[0] - d[0];
let y = Aalpha[1] + dp[1] - d[1];
if (math.abs(x - beta[0]) < eps && math.abs(y - beta[1]) < eps) {
edges.push({
source: i,
target: j,
f: new AffineFunction([AInv, math.multiply(AInv, d)])
});
}
});
});
}
}
return new DigraphIFS(edges);
}
Insert cell
Insert cell
digraphIFS.dimension
Insert cell
Insert cell
digraphIFS.show_digraph()
Insert cell
Insert cell
Insert cell
digraphIFS.render_stochastic({
image_width: width < 500 ? width : 500,
n: 100000,
colors: true,
color_depth: 4
})[6]
Insert cell
Insert cell
f_invs = fs.map((af) => af.invert())
Insert cell
IFS = new IteratedFunctionSystem(fs)
Insert cell
F = [
[1, 0],
[1, 1],
[0, 1],
[-1, 0],
[-1, -1],
[0, -1]
]
Insert cell
fs = D.map((d) => new AffineFunction([AInv, math.multiply(AInv, d)]))
Insert cell
D = [
[0, 0],
[1, 0]
]
Insert cell
AInv = math.inv(A)
Insert cell
A = [
[1, 1],
[-1, 1]
]
Insert cell
// Used for pre-generated images:
//
// attractor = IFS.deterministic_path_approximation({
// init: [
// [0, 0],
// [1, -1],
// [2, 0],
// [1, 1]
// ],
// max_depth: 15
// }).flat(1)
Insert cell
Insert cell
import {
IteratedFunctionSystem,
AffineFunction,
shift,
scale,
rotate,
degree
} from "@mcmcclur/iteratedfunctionsystem-class"
Insert cell
import { DigraphIFS } from "@mcmcclur/digraphifs-class"
Insert cell
math = require("mathjs")
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