Skip to content

Instantly share code, notes, and snippets.

@mango314
Last active December 10, 2015 00:59
Show Gist options
  • Save mango314/4355233 to your computer and use it in GitHub Desktop.
Save mango314/4355233 to your computer and use it in GitHub Desktop.
Cool square-tiling thingy.

Square Tilings - and the Pythagorean Theorem

Written in Mathematica. Probably can be ported to d3.js

Alt text

sq[{x_, y_}, r_] := { EdgeForm[Thick],
Polygon[{{x, y}, {x + r, y}, {x + r, y + r}, {x, y + r}, {x, y}}]}
t = 0.25;
a = Cos[t];
b = Sin[t];
motif[a_, b_] := (
v = {b, a};
w = {a, -b};
x = {b, 0};
{Blue, sq[0 v + 0 w, b], Red, sq[x, a]})
tiling[s_] :=
Graphics[Table[
Translate[motif[Cos[2 Pi s], Sin[2 Pi s]], m w + n v], {m, 0,
5}, {n, 0, 5}]]
Export["*.gif",
Table[tiling[s], {s, 0, 0.5, 0.01}]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment