(* IFS for a disk using two maps *) (* Mathematica 3.0 code *) (* written by Will Gilbert, Univ of Waterloo, Aug 1993 *) (* n = number of points, e.g. 1000 *) (* In polars, r = radius, a = angle *) DiskIFS0[n_] := Block[{r = Random[], a = 2 Pi Random[], pts = {}, rr}, For[i=0, i < n, i++, rr = N[a/(2*Pi)]; a = N[Pi(r + Random[Integer])]; r = rr; AppendTo[pts, {r*Cos[a], r*Sin[a]}] ]; ListPlot[pts, PlotStyle->{PointSize[0.01]}, PlotRange->{{-1,1},{-1,1}}, AspectRatio->Automatic ] ] DiskIFS0[1000] (* IFS for a disk with constant density, using two maps *) (* Mathematica 3.0 code *) (* written by Will Gilbert, Univ of Waterloo, Aug 1993 *) (* n = number of points, e.g. 1000 *) (* In polars, r = radius, a = angle *) DiskIFS[n_] := Block[{r = Random[], s, pts = {}, j, rr}, s = r*Random[]; For[i=0, i < n, i++, j = Random[Integer]; rr = 0.5*s + r*(0.5 - j) + j; s = 0.5*r + s*(j - 0.5); r = rr; a = If[r==0, 0, N[2*Pi*s/r]]; AppendTo[pts, {r*Cos[a], r*Sin[a]}] ]; ListPlot[pts, PlotStyle->{PointSize[0.01]}, PlotRange->{{-1,1},{-1,1}}, AspectRatio->Automatic ] ] DiskIFS[1000] (* IFS for a disk with constant density, using two maps *) (* with two colours *) (* Mathematica 3.0 code *) (* written by Will Gilbert, Univ of Waterloo, Aug 1993 *) (* n = number of points, e.g. 1000 *) (* r = radius in polars, a = angle, *) (* 0 <= r <= 1, -r <= s <= r, j = 0 or 1 *) DiskIFS2[n_] := Block[{r = Random[], s, pts, j, rr}, s = r*Random[]; pts[0] = {}; pts[1] = {}; For[i=0, i < n, i++, j = Random[Integer]; rr = 1 - 0.5*r - (0.5 - j)*s; s = (0.5 - j)*r - 0.5*s; r = rr; a = If[r==0, 0, N[(Pi*s/r)]]; AppendTo[pts[j], Point[{r*Cos[a],r*Sin[a]}]] ]; Show[Graphics[{ {PointSize[0.01], RGBColor[0,0,1], pts[0]}, {PointSize[0.01], RGBColor[1,0,0], pts[1]}}], PlotRange->{{-1,1},{-1,1}}, AspectRatio->Automatic, Axes -> True ] ] DiskIFS2[1000] (* IFS for a disk with constant density, using two maps *) (* with four colours *) (* Mathematica 3.0 code *) (* written by Will Gilbert, Univ of Waterloo, May 1994 *) (* n = number of points, e.g. 1000 *) (* r = radius in polars, a = angle, *) (* 0 <= r <= 1, -r <= s <= r *) (* j = 0 or 1, j1 = 0 or 1 *) DiskIFS4[n_] := Block[{r = Random[], s, pts, j, j1, rr}, s = r*Random[]; pts[0] = {}; pts[1] = {}; pts[2] = {}; pts[3] = {}; For[i=0, i < n, i++, j = Random[Integer]; rr = 1 - 0.5*r - (0.5 - j)*s; s = (0.5 - j)*r - 0.5*s; r = rr; a = If[r==0, 0, N[(Pi*s/r)]]; AppendTo[pts[2*j1+j], Point[{r*Cos[a],r*Sin[a]}]]; j1 = j ]; Show[Graphics[{ {PointSize[0.01], RGBColor[0,0.7,1], pts[0]}, {PointSize[0.01], RGBColor[1,0,0], pts[1]}, {PointSize[0.01], RGBColor[0,0,1], pts[2]}, {PointSize[0.01], RGBColor[1,0.5,0], pts[3]}}], PlotRange->{{-1,1},{-1,1}}, AspectRatio->Automatic, Axes -> True ] ] DiskIFS4[1000] (* Yin-Yang IFS for a disk, *) (* using two maps with two colours *) (* Mathematica 3.0 code *) (* written by Will Gilbert, Univ of Waterloo, May 1994 *) (* n = number of points, e.g. 1000 *) (* r = radius in polars, a = angle, *) (* 0 <= r <= 1, -r <= s <= r, j = 0 or 1 *) YinYangIFS[n_] := Block[{r = Random[], s, pts, j, rr, a}, s = r*Random[]; pts[0] = {}; pts[1] = {}; For[i=0, i < n, i++, j = Random[Integer]; rr = 1 - 0.5*r - (0.5 - j)*s; s = (0.5 - j)*r - 0.5*s; r = rr; a = If[r==0, 0, N[(Pi*s/r) + ArcCos[r]]]; AppendTo[pts[j], Point[{r*Cos[a],r*Sin[a]}]] ]; Show[Graphics[{ {PointSize[0.01], RGBColor[0,0,1], pts[0]}, {PointSize[0.01], RGBColor[1,0,0], pts[1]}}], PlotRange->{{-1,1},{-1,1}}, AspectRatio->Automatic, Axes -> True ] ] YinYangIFS[1000] (* Yin-Yang IFS for a disk, *) (* using two maps with four colours *) (* Mathematica 3.0 code *) (* written by Will Gilbert, Univ of Waterloo, May 1994 *) (* n = number of points, e.g. 1000 *) (* r = radius in polars, a = angle, *) (* 0 <= r <= 1, -r <= s <= r, j = 0 or 1 *) YinYangIFS4[n_] := Block[{r = Random[], s, pts, j, j1, rr, a}, s = r*Random[]; pts[0] = {}; pts[1] = {}; pts[2] = {}; pts[3] = {}; For[i=0, i < n, i++, j = Random[Integer]; rr = 1 - 0.5*r - (0.5 - j)*s; s = (0.5 - j)*r - 0.5*s; r = rr; a = If[r==0, 0, N[(Pi*s/r) + ArcCos[r]]]; AppendTo[pts[2*j1+j], Point[{r*Cos[a],r*Sin[a]}]]; j1 = j ]; Show[Graphics[{ {PointSize[0.01], RGBColor[0,0.7,1], pts[0]}, {PointSize[0.01], RGBColor[1,0,0], pts[1]}, {PointSize[0.01], RGBColor[0,0,1], pts[2]}, {PointSize[0.01], RGBColor[1,0.5,0], pts[3]}}], PlotRange->{{-1,1},{-1,1}}, AspectRatio->Automatic, Axes -> True ] ] YinYangIFS4[1000]