Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

The question is, how might I get the following script working as a CDF demo of complex inversion in a circle? It works fine in my home edition of MMA 8 run on OS X Mavericks. When saved as a CDF file and opened with the CDF Player, it produced an error:

Show::gcomb: "Could not combine the graphics objects in Show[{circleK,circleAPlot[2\ oCircA],circleBPlot[2\ oCircA],invLineGraphics[2\ oCircA],invAVGrPts[2\ oCircA],invLVGrPts[2\ oCircA],caption},labels[2\ oCircA],Axes->False,PlotRange->{xBnds,yBnds},Background->GrayLevel[1]]"

SaveDefinitions -> True has no visible effect. Normally, I would simplify for a question like this, but having scant experience with CDF files, I don't really know where to begin, and perhaps the comments and labels will help to reveal the structure of the program.

Clear["Global`*"]

(* CONSTANTS *)

radCircA = 1/4; (* Radius of A *)

oCircA = (1+I)/(4 Sqrt[2]); (* Center of A *)

radR = 1; (* Radius of K *)

q = 0; (* Center of K *)

(* PLOTTING BOUNDARIES *)

bnds = 4;

xBnds = {-bnds,bnds};

yBnds = {-bnds,bnds};

(* FUNCTIONS *)

(* THE POINT OF THE PLOT IS TO DEMONSTRATE THE BEHAVIOR OF THIS FUNCTION, Subscript[I, k](z), R = 1 *)

zInv[z_,q_,R_]:=(q Conjugate[z] + (R^2 - Abs[q]^2)/(Conjugate[z]-Conjugate[q]))

(* CONVERT COMPLEX TO VECTOR w REAL ELEMENTS *)

v[z_]:={Re[z],Im[z]};

(* CIRCLE WITH ORIGIN AT q AND RADIUS OF radR *)

circleK := Graphics[Circle[v[q],radR]];

(* CALCULATE COMPLEX POINTS OF CIRCLE A AND USE TABLE TO CREATE LIST OF POINTS *)

circleATable[centerA_] := Table[radCircA Exp[I \[Theta]]+centerA, {\[Theta], 0, 2Pi, .1}];

(* INVERT COMPLEX POINTS OF CIRCLE A BY MAPPING zInv[] TO LIST OF COMPLEX POINTS; RETURNS A LIST *)

circleBTable[centerA_] := zInv[#,q,radR]&/@circleATable[centerA];

(* MAP LISTS OF COMPLEX POINTS TO LISTS OF VECTORS *)

circleAVectors[centerA_] := v[#]&/@circleATable[centerA];

lineBVectors[centerA_] := v[#]&/@circleBTable[centerA];

(* CREATE LINE PLOTS FROM LISTS OF VECTORS *)

circleAPlot[centerA_] := ListLinePlot[circleAVectors[centerA],AspectRatio->1,PlotStyle->{Blue}];

circleBPlot[centerA_] := ListLinePlot[lineBVectors[centerA],AspectRatio->1,PlotStyle->{Blue}];

(* INVERSION POINTS IN A, SHOWN WITH RED DOTS AND ARROWS *)

invAngles := Range[Pi/4, 3Pi/4, Pi/8];

invACPts[centerA_] := (radCircA Exp[I (#-Pi/4)]+centerA)&/@invAngles;

invLCPts[centerA_] := zInv[#,q,radR]&/@invACPts[centerA];

invAVGrPts[centerA_] :=Graphics[{Red,Point[v[#]]}&/@invACPts[centerA]];

invLVGrPts[centerA_]:= Graphics[{Red,Point[v[#]]}&/@invLCPts[centerA]];

invLineObjs[centerA_] := {Gray, Dashed,Arrowheads[.02],Arrow[{v[0],v[#]}]}&/@invLCPts[centerA];

invLineGraphics[centerA_] := Graphics[invLineObjs[centerA]];

(* LABELS *)

labelK=Text[Style["K", Bold, 12], v[-.5-.5I]];

labelA[centerA_] := {Blue,Text[Style["A", Bold, 8], v[centerA]]};

labelB[centerA_] :={Blue,Text[Style[If[Abs[centerA] == Abs[oCircA], "B = L","B"], Bold, 8], v[zInv[centerA +radCircA Exp[I  Pi/4],q,radR]+.2+.2I]]};

labelq = Text[Style["q", Bold, 12], v[0]-{.1,.1}];

(* CONVERT TEXT PRIMITIVES TO GRAPHICS OBJECTS *)

labels[centerA_] := Graphics[{labelK, labelA[centerA], labelB[centerA],labelq}];

caption = Graphics[{Text[Style["Complex inversion of circle A in unit circle K\nto circle B or to line L if origin q of K in A\nSubscript[I, k](z) =(q Overscript[z, _] + ((R^2)-|q|^2) )/(Overscript[z, _]-Overscript[q, _]), R=1", Bold,12], v[-2.2I]]}];

(* GRAPHICS AND PLOTS COMBINED USING SHOW; LAST ITEM IN TRUMPS PREVIOUS *)

Manipulate[
Show[{circleK,circleAPlot[offset oCircA],circleBPlot[offset oCircA],invLineGraphics[offset oCircA],invAVGrPts[offset oCircA],invLVGrPts[offset oCircA],caption,labels[offset oCircA]},Axes->False,PlotRange->{xBnds,yBnds},Background->White],
{{offset,2,"origin A multiplier"}, {3,2.5,2,1.5, 1, .5, 0,-.5}}
]
share|improve this question
    
Take a look at SaveDefinitions. –  Kuba Jun 25 at 21:17
    
@Kuba, I tried SaveDefinitions before posting the program. It made no difference. –  Gary Palmer Jun 25 at 21:53

1 Answer 1

up vote 2 down vote accepted

You need to have all the functions in the Initialization section. This is the first thing Manipulate evaluates. This works. Tested it in CDF. Opened in CDF player OK.

Manipulate[
 Show[{
   circleK,
   circleAPlot[offset oCircA],
   circleBPlot[offset oCircA],
   invLineGraphics[offset oCircA],
   invAVGrPts[offset oCircA],
   invLVGrPts[offset oCircA],
   caption,
   labels[offset oCircA]
   }, Axes -> False,
  PlotRange -> {xBnds, yBnds}, Background -> White],

 {{offset, 2, "origin A multiplier"}, {3, 2.5, 2, 1.5, 1, .5, 0, -.5}},

 Initialization :>
  (
   radCircA = 1/4;(*Radius of A*)
   oCircA = (1 + I)/(4 Sqrt[2]);(*Center of A*)
   radR = 1;(*Radius of K*)
   q = 0;(*Center of K*)(*PLOTTING BOUNDARIES*)
   bnds = 4;
   xBnds = {-bnds, bnds};
   yBnds = {-bnds, bnds};

   (*FUNCTIONS*)
   zInv[z_, q_, R_] :=(q Conjugate[z] + (R^2 - Abs[q]^2)/(Conjugate[z]-Conjugate[q]));
   (*CONVERT COMPLEX TO VECTOR w REAL ELEMENTS*)
   v[z_] := {Re[z], Im[z]};
   (*CIRCLE WITH ORIGIN AT q AND RADIUS OF radR*)
   circleK := Graphics[Circle[v[q], radR]];
   (*CALCULATE COMPLEX POINTS OF CIRCLE A AND USE TABLE TO CREATE LIST OF POINTS*)

   circleATable[centerA_] := 
     Table[radCircA Exp[I \[Theta]] + centerA, {\[Theta], 0, 2 Pi, .1}];

   circleBTable[centerA_] := zInv[#, q, radR] & /@ circleATable[centerA];
   (*MAP LISTS OF COMPLEX POINTS TO LISTS OF VECTORS*)
   circleAVectors[centerA_] := v[#] & /@ circleATable[centerA];
   lineBVectors[centerA_] := v[#] & /@ circleBTable[centerA];
   (*CREATE LINE PLOTS FROM LISTS OF VECTORS*)
   circleAPlot[centerA_] := 
     ListLinePlot[circleAVectors[centerA], AspectRatio -> 1, PlotStyle -> {Blue}];
   circleBPlot[centerA_] := 
      ListLinePlot[lineBVectors[centerA], AspectRatio -> 1, PlotStyle -> {Blue}];
   (*INVERSION POINTS IN A,SHOWN WITH RED DOTS AND ARROWS*)
   invAngles := Range[Pi/4, 3 Pi/4, Pi/8];
   invACPts[centerA_] := (radCircA Exp[I (# - Pi/4)] + centerA) & /@ invAngles;
   invLCPts[centerA_] := zInv[#, q, radR] & /@ invACPts[centerA];
   invAVGrPts[centerA_] := Graphics[{Red, Point[v[#]]} & /@ invACPts[centerA]];
   invLVGrPts[centerA_] := Graphics[{Red, Point[v[#]]} & /@ invLCPts[centerA]];
   invLineObjs[centerA_] := {Gray, Dashed, Arrowheads[.02], 
      Arrow[{v[0], v[#]}]} & /@ invLCPts[centerA];
   invLineGraphics[centerA_] := Graphics[invLineObjs[centerA]];
   (*LABELS*)
   labelK = Text[Style["K", Bold, 12], v[-.5 - .5 I]];
   labelA[centerA_] := {Blue, Text[Style["A", Bold, 8], v[centerA]]};
   labelB[centerA_] := {Blue, 
     Text[Style[If[Abs[centerA] == Abs[oCircA], "B = L", "B"], Bold, 8], 
      v[zInv[centerA + radCircA Exp[I Pi/4], q, radR] + .2 + .2 I]]};
   labelq = Text[Style["q", Bold, 12], v[0] - {.1, .1}];
   (*CONVERT TEXT PRIMITIVES TO GRAPHICS OBJECTS*)
   labels[centerA_] := Graphics[{labelK, labelA[centerA], labelB[centerA], labelq}]; 
   caption = Graphics[{Text[
    Style["Complex inversion of circle A in unit circle K\nto circle B or to line L if origin q of K in A\nSubscript[I, k](z) \
=(q Overscript[z, _] + ((R^2)-|q|^2) )/(Overscript[z, _]-Overscript[q, _]), R=1", Bold, 12], v[-2.2 I]]}
     ];

   )
 ]

Mathematica graphics

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.