
(*----------------------------------------------------*)
(* Groups of reflections: i=0,1,2
   ERefi : through sides of T
   MRefi : ERefi in GL_2(R)
   IRefi : through sides of I
*)

(* Reflections through sides of equilateral
   triangle spanned with vertices (-1)^(1/3) 
   Refi moves Omega^i, fixes others
*)
ERef0[z_]:=(-1-Re[z])+I Im[z]
ERef1[z_]:=ERef0[z/Omega]*Omega
ERef2[z_]:=ERef0[Omega*z]/Omega

(* Reflections through sides of ideal
   triangle spanning 0, 1, Inf
   Refi moves Inf,0,1, i=0,1,2
*)
IRef0[z_]:=1/2 + 1/Conjugate[4*z-2]
IRef1[z_]:= 2-Re[z] + I Im[z]
IRef2[z_]:=  -Re[z] + I Im[z]

(* Matrix form of an affine map f : C -> C *)
Matrix[f_]:={{Re[f[1]-f[0]],
	      Re[f[I]-f[0]],
	      Re[f[0]]},
	     {Im[f[1]-f[0]],
	      Im[f[I]-f[0]],
	      Im[f[0]]},
	      {0,0,1}}

MRef0=Matrix[ERef0]
MRef1=Matrix[ERef1]
MRef2=Matrix[ERef2]

(* Utility:  apply an affine map to a complex number *)
Aff[g_,z_]:=Drop[g.{Re[z],Im[z],1},-1]
