(*   This is the file MakeFramesSquares.m, written by

     Douglas N. Arnold  <dna@math.psu.edu>
     Department of Mathematics
     Penn State
     University Park, PA  16802
     
     January 1997
*)
      
Needs["homotopyframes`"]
Needs["Graphics`Colors`"]

(* This file makes two sets of PPM files to be combined to make two
   animations showing how four small squares are deformed under an
   analytic and a non-analytic cubic polynomial transformation of the
   plane.  The image of the squares is shown as the identity is deformed
   by linear homotopy to the mapping. *)

         (* STEP 1: DESCRIBE THE DESIRED ANIMATIONS *)
         
f0[z_]:=z                   (* initial and final functions *)
f1[z_]:=(z^3-3z^2-1)/(1+3I)         (*   of the homotopies *)
f2[z_]:=(z^3-3Conjugate[z]^2-1)/(1+3I)

llplot=-1-I;                (* lower left and upper right corners of *)
urplot=-llplot;             (*   plotting region *)

nframes=11;                 (* number of frames in the animation *)

width=400                   (* frame width in pixels *)

height=400                  (* frame height in pixels *)

options =                   (* plot options for each frame *)
  {Background->Black, DefaultColor->White, AspectRatio->Automatic};

(* describe the squares *)
a=(1+I)/2;
d=.2;
nl=5;
squares = Union[
  linearray[a,(1+d)a,nl,nl,PlotStyle->{{Thickness[.005],Magenta}}],
  linearray[-a,-(1+d)a,nl,nl,PlotStyle->{{Thickness[.005],Green}}],
  linearray[Conjugate[a],(1+d)Conjugate[a],nl,nl,PlotStyle->{{Thickness[.005],Cyan}}],
  linearray[-Conjugate[a],-(1+d)Conjugate[a],nl,nl,PlotStyle->{{Thickness[.005],Yellow}}]];


                     (* STEP 2: MAKE THE ANIMATIONS *)

homotopyframes[
  (* initial function *)
    f0,
  (* final function *)
    f1,
  (* curvelist *)
    squares,
  (* number of frames *)
    nframes,
  (* width and height *)
    width, height,
  (* filename prefix *)
    "squares1-",
  (* Show options (for each frame) *)
    options,
    PlotRange->{{Re[llplot],Re[urplot]},{Im[llplot],Im[urplot]}}
];

Print[StringJoin["-- wrote frames for squares1" --"]]

