Linethickness = 0.5pt;
beginfig(1);
recursion_depth := 6;
const := 2.2;
picture reds, blues, greens;
blues := reds := greens := currentpicture;
vardef orbitdots(expr iter, maxiter, xoffset, yoffset, lastg) =
save offlen;
offlen := 1.3in/(const**iter);
if lastg = "":
addto blues doublepath (xoffset, yoffset) withpen pencircle scaled 2bp withcolor blue;
if iter <= maxiter:
orbitdots(iter 1, maxiter, xoffset offlen, yoffset, "a");
orbitdots(iter 1, maxiter, xoffset - offlen, yoffset, "a-1");
orbitdots(iter 1, maxiter, xoffset, yoffset offlen, "b");
orbitdots(iter 1, maxiter, xoffset, yoffset - offlen, "b-1");
fi;
fi;
if lastg = "a":
addto greens doublepath (xoffset, yoffset) withpen pencircle scaled 2bp withcolor 0.8green;
if iter <= maxiter:
orbitdots(iter 1, maxiter, xoffset offlen, yoffset, "a");
orbitdots(iter 1, maxiter, xoffset, yoffset offlen, "b");
orbitdots(iter 1, maxiter, xoffset, yoffset - offlen, "b-1");
fi;
fi;
if lastg = "a-1":
addto reds doublepath (xoffset, yoffset) withpen pencircle scaled 1.2bp withcolor red;
addto blues doublepath (xoffset, yoffset) withpen pencircle scaled 2bp withcolor blue;
if iter <= maxiter:
orbitdots(iter 1, maxiter, xoffset, yoffset offlen, "b");
orbitdots(iter 1, maxiter, xoffset - offlen, yoffset, "a-1");
orbitdots(iter 1, maxiter, xoffset, yoffset - offlen, "b-1");
fi;
fi;
if lastg = "b":
addto blues doublepath (xoffset, yoffset) withpen pencircle scaled 2bp withcolor blue;
if iter <= maxiter:
orbitdots(iter 1, maxiter, xoffset offlen, yoffset, "a");
orbitdots(iter 1, maxiter, xoffset, yoffset offlen, "b");
orbitdots(iter 1, maxiter, xoffset - offlen, yoffset, "a-1");
fi;
fi;
if lastg = "b-1":
addto blues doublepath (xoffset, yoffset) withpen pencircle scaled 2bp withcolor blue;
if iter <= maxiter:
orbitdots(iter 1, maxiter, xoffset offlen, yoffset, "a");
orbitdots(iter 1, maxiter, xoffset - offlen, yoffset, "a-1");
orbitdots(iter 1, maxiter, xoffset, yoffset - offlen, "b-1");
fi;
fi;
enddef;
numeric length;
length := 1.3in / (const**recursion_depth);
pickup pencircle scaled Linethickness;
picture p, q, r;
for i = 1 upto recursion_depth - 2:
draw (0,0) -- (length,0);
draw (0,-length) -- (0,length);
length := length * const;
currentpicture := currentpicture shifted (length,0);
p := currentpicture rotated 90;
q := p yscaled -1;
addto currentpicture also p;
addto currentpicture also q;
endfor;
draw (0,0) -- (length,0);
draw (0,-length) -- (0,length);
length := length * const;
currentpicture := currentpicture shifted (length,0);
p := currentpicture rotated 90;
q := p yscaled -1;
r := currentpicture xscaled -1;
addto currentpicture also p;
addto currentpicture also q;
addto currentpicture also r;
draw (-length,0) -- (length,0);
draw (0,-length) -- (0,length);
dotlabel.urt(btex$e$etex, (0,0));
dotlabel.ulft(btex$a$etex, (length,0));
dotlabel.lrt(btex$b$etex, (0,length));
label.top(btex$S(a^{-1})$etex, (-1.2length, 0.9length)) withcolor red;
label.bot(btex$aS(a^{-1})$etex, (-1.3length,-0.9length)) withcolor blue;
label.rt(btex$S(a)$etex, (1.1length,1.1length)) withcolor 0.8green;
orbitdots(1, recursion_depth-2, 0, 0, "");
addto currentpicture also greens;
addto currentpicture also blues;
addto currentpicture also reds;
currentpicture := currentpicture shifted (10cm,10cm);
currentpicture := currentpicture scaled 3.5;
endfig;
end;