Note

This Mathematica notebook is from the WWW project A Visual Dictionary of Special Plane Curves. Copyright © 1995-2000 by Xah Lee. (http://xahlee.org/)

Packages and Initializations

Needs["Transform2DPlot`"]

Clear[inversion]

inversion::usage = "
inversion[{c1,c2}, r] returns a pure function f:R^2->R^2, where f is
the inversion transformation with center {c1,c2} and radius r.
inversion[] is a shorthand for inversion[{0,0}, 1].
Usage Example: inversion[{1,1}, 2][x,y]";

inversion[ {c1_, c2_}, r_] :=
Function[
	If[ N@{c1,c2} == N@{#1,#2},
		{Infinity, Infinity},
		( ({#1,#2}-{c1,c2})/ (Plus@@(({#1,#2}-{c1,c2})^2) ) r^2 +{c1,c2})
	]
] /; And@@(NumberQ /@ N[{c1, c2, r}])


inversion[][0,0] := {Infinity, Infinity}
inversion[] := Function[({#1,#2})/ (Plus@@(({#1,#2})^2) )]

Inversion on Grids

This notebook contain code that generates some graphics on inversion, using the package Transform2DPlot.m.

Inversion of rectangular grids.

Transform2DPlot[ {x,y}, {x,-5, 5}, {y,-5, 5},Background->GrayLevel[0],Frame->True,Axes->False];

Transform2DPlot[ inversion[], {-5, 5}, {-5, 5},Background->GrayLevel[0]];

Inversion on an array of squares.

Clear[iMin, iMax, iStep, side, bound, gp]
iMin = -4. ;
iMax = 4. ;
iStep = (iMax - iMin)/16;
side = iStep  .8;
bound =  .1;

    
gp = 
        Table[Rectangle[{i - side/2, j - side/2}, {i + side/2, 
              j + side/2}], {i, iMin, iMax, N@iStep}, {j, iMin, iMax, 
            N@iStep}];

    
\(\(\(gp = 
        gp /. rect : Rectangle[{x_, y_}, __] :> 
            If[\((\(-bound\) < x + side/2 < bound)\) && \((\(-bound\) < 
                    y + side/2 < bound)\), deleteMe, rect];\)\(
\)
    \)\)
gp = 
        Graphics[
          DeleteCases[gp, deleteMe, {-1}] /. 
            rect : Rectangle[{x_, 
                    y_}, __] :> {Hue[(ArcTan[x, 
                        y])/(2 Pi), 
                  1 - Sqrt[Plus @@ (({x, y}^2))]/6, 1], 
                rect}];

Transform2DGraphicsPlot[
      Show[gp, AspectRatio -> Automatic, 
        Background -> GrayLevel[0], Frame -> True], inversion[], 
      ResolutionLength ->  .1, AspectRatio -> Automatic, 
      Background -> GrayLevel[0], 
      PlotRange -> {{-1, 1}, {-1, 1}} 1.7, 
      Frame -> True]

Inversion of triangular grid.

Set ResolutionLength-> .025 for smooth graphics.

Transform2DGraphicsPlot[
	Show[
		Graphics[
			TriangularGrid[1.2, 26,
				{Hue[.35,1-#,.8]&, Hue[0,#,.8]&, Hue[.7,#,.8]&}]
		],
		AspectRatio->Automatic,
		Background->GrayLevel[0]
	],
	inversion[],
	ResolutionLength->.05,
	Axes->False,
	AspectRatio->Automatic,
	PlotRange->{{-1,1},{-1,1}} 4.5,
	Background->GrayLevel[0]
];

Repeated inversion of circles.

Repeated inversion of circles.
The pre-image is n non-overlapping circles evenly distributed around the origin, plus a circle centered around the origin but not touching the others.

Clear[n, nestLevel, resolution, li, gra]

n = 3;  (*n is the number of circles . Try 2, 3, 4, 5, 6*) 
      nestLevel = 2;  (*greater than 2 may take a long time*) 
      resolution =  .05;  (*smaller == smoother == 
        longer*)  (*this generate n circles distributed around a center*) li = 
      N@Rest@Table[
            Circle[{Sin@t, Cos@t},  .98 Sin[(2 Pi/n)/2]], {t, 0, 2 Pi, 
              2 Pi/n}];
 (*this adds a center circle*) 
\(\(li = 
        N@Join[li, {Circle[{0, 0}, 
                1 - Sin[\((2\ Pi/n)\)/
                      2]]}];\)

 (*adds\ color*) \)
gra = 
        N@Transpose[{Rest@Table[Hue[i], {i, 0, 1, 1/(Length@li)}], 
              li}];

\(\(\( (*may\ take\ a\ minute\ or\ \(\(more\)\(.\)\)*) \)\(\(result = 
        Nest[Outer[
              g@\(First@
                    Transform2DGraphicsPlot[#1, #2, 
                      ResolutionLength -> resolution, 
                      DisplayFunction -> Identity]\) &, g@#, 
              g @@ \((li /. Circle -> inversion)\)] &, g@gra, 
          nestLevel];\)\(
\)\(
\)
    \( (*Note : 
        an\ intermediate\ head\ g\ must\ be\ used\ because\ otherwise\ Outer\ will\ pick\ any\ small\ element\ in\ the\ Graphics . 
            With\ a\ temporary\ head\ g, 
      Outer\ will\ only\ pair\ elements\ with\ head\ g\ only . Also, 
      the\ temporary\ head\ cannot\ be\ Graphics, because, 
      arguments\ other\ then\ the\ first\ in\ Graphics\ will\ automatically\ be\ deleted, 
      presumably\ because\ Graphics\ is\ defined\ to\ take\ only\ one\ argument, with\ the\ rest\ being\ \(\(options\)\(.\)\)*) \)\)\)\)

Show[Graphics[result /. g -> List], 
        AspectRatio -> Automatic, 
        PlotRange -> {{-1, 1}, {-1, 1}}, 
        Background -> GrayLevel[0]];