Published
Edited
Dec 9, 2021
2 stars
Also listed in…
Math
Fractal tiling
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// Approximations to the Eisenstein fractions via a series
// i.e. the second image above

pts = {
let n = 7;
let b = -2;
let D = [
math.complex(0, 0),
math.complex(1, 0),
math.pow(-1, 2 / 3),
math.pow(-1, 4 / 3)
];

let v = [math.complex(0, 0)];
for (let i = 1; i <= n; i++) {
v = v
.map((z) =>
D.map(function (d, j) {
let z_new = math.add(math.divide(d, b), math.multiply(z, 1 / b));
if (i == n) {
z_new.last = j;
}
return z_new;
})
)
.flat();
}

return v; // .map((z) => [z.re, z.im]);
}
Insert cell
// The Eisenstein fractions as a self-affine tile,
// i.e. the first image above.

T = {
let T = [
[
[
[0, 0],
[1, 0],
[1, 1],
[0, 1]
]
]
];
let n = 7;
for (let i = 0; i < n; i++) {
T = multi_polygon_step(T, i);
}
let An = math.pow(math.inv(A), n);
let S = [
[1, -1 / 2],
[0, math.sqrt(3) / 2]
];
T = T.map((p) => p.map((pts) => pts.map((xy) => math.multiply(S, An, xy))));
return T;
}
Insert cell
function multi_polygon_step(mp, n) {
return polygonClipping.union(...mp.map((p) => polygon_step(p, n)));
}
Insert cell
function polygon_step(p, n) {
let An = math.pow(A, n);
return D.map(function (d) {
return p.map((a) => a.map((aa) => math.add(math.multiply(An, d), aa)));
});
}
Insert cell
A = [
[2, -2],
[2, 0]
]
Insert cell
D = [
[0, 0],
[1, 0],
[0, 1],
[-1, -1]
]
Insert cell
import {
IteratedFunctionSystem,
AffineFunction
} from "@mcmcclur/self-affine-tiles"
Insert cell
math = require('mathjs')
Insert cell
polygonClipping = require("polygon-clipping")
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