(* ::Package:: *)

(************************************************************************)
(* This file was generated automatically by the Mathematica front end.  *)
(* It contains Initialization cells from a Notebook file, which         *)
(* typically will have the same name as this file except ending in      *)
(* ".nb" instead of ".m".                                               *)
(*                                                                      *)
(* This file is intended to be loaded into the Mathematica kernel using *)
(* the package loading commands Get or Needs.  Doing so is equivalent   *)
(* to using the Evaluate Initialization Cells menu command in the front *)
(* end.                                                                 *)
(*                                                                      *)
(* DO NOT EDIT THIS FILE.  This entire file is regenerated              *)
(* automatically each time the parent Notebook file is saved in the     *)
(* Mathematica front end.  Any changes you make to this file will be    *)
(* overwritten.                                                         *)
(************************************************************************)



(* ::Input::Initialization:: *)
Print["Loading PolyPlot.m from http://drorbn.net/to24/ap to plot 2-variable polynomials."]


(* ::Input::Initialization:: *)
PolyPlot[{\[CapitalDelta]_,\[Theta]_}]:=Module[{crs,m,m1,m2,maxc,minc,s,rect,hex},GraphicsColumn[{
rect={{0,0},{1,0},{1,1},{0,1}};
hex=Table[{Cos[\[Alpha]],Sin[\[Alpha]]}/Cos[2\[Pi]/12]/2, {\[Alpha],2\[Pi]/12,2\[Pi],2\[Pi]/6}];
If[Expand[\[CapitalDelta]]===0,Graphics[],
m=Max[-Exponent[\[CapitalDelta],T,Min], Exponent[\[CapitalDelta],T,Max]];
crs=CoefficientRules[T^m \[CapitalDelta],{T}];
maxc=N@Log@Max@Abs[Last/@crs];
minc=N@Log@Min@Select[Abs[Last/@crs],#>0&];
If[minc==maxc,s[_]=0,s[c_]:=s[c]=(maxc-Log@c)/(maxc-minc)];
Graphics[crs/.({x_}->c_):>{
Lighter[Which[c==0, White,c>0, Red,c<0,Blue], 0.88s[Abs@c]],
Tooltip[Polygon[({x+m-1/2,0}+#)&/@rect],c]
},AspectRatio->Min[1/5 ,1/Sqrt[m+1]],ImagePadding->None,PlotRangePadding->None]
],
If[Expand[\[Theta]]===0,Graphics[{White,Disk[]}],
m1=Max[-Exponent[\[Theta],Subscript[T, 1],Min], Exponent[\[Theta],Subscript[T, 1],Max]];
m2=Max[-Exponent[\[Theta],Subscript[T, 2],Min], Exponent[\[Theta],Subscript[T, 2],Max]];
crs=CoefficientRules[\!\(
\*SubsuperscriptBox[\(T\), \(1\), \(m1\)] 
\*SubsuperscriptBox[\(T\), \(2\), \(m2\)] \[Theta]\),{Subscript[T, 1],Subscript[T, 2]}];
maxc=N@Log@Max@Abs[Last/@crs];
minc=N@Log@Min@Select[Abs[Last/@crs],#>0&];
If[minc==maxc,s[_]=0,s[c_]:=s[c]=(maxc-Log@c)/(maxc-minc)];
Graphics[{{White,Disk[{0,0},1+Cos[2\[Pi]/12]Norm[{m1,m2}]/Sqrt[2]]},
crs/.({x1_,x2_}->c_):>{
Lighter[Which[c==0, White,c>0, Red,c<0,Blue], 0.88s[Abs@c]],
Tooltip[Polygon[(({
 {1, -1/2},
 {0, Sqrt[3]/2}
}) . {x1-m1,x2-m2}+#)&/@hex],c] 
}
},ImagePadding->None,PlotRangePadding->None]
]
},Spacings -> Scaled@0.08,ImagePadding->None,PlotRangePadding->None]];



